Skip to the content.

This example is based on the source code:
https://github.com/jetsung/docker-nginx-php/tree/main/example

Docker Hub

Nginx-PHP: https://hub.docker.com/r/devcto/nginx-php

English 简体中文

Include extensions

bcmath,Core,ctype,curl,date,dom,exif,fileinfo,filter,ftp,gd,gettext,hash,iconv,intl,json,libxml,mbstring,mysqli,mysqlnd,openssl,pcntl,pcre,PDO,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,Phar,posix,redis,Reflection,session,shmop,SimpleXML,soap,sockets,sodium,SPL,sqlite3,standard,sysvsem,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib

Custom extension

Command line tools

Use docker exec {CONTAINER ID} {COMMAND}

# Current process
docker exec {CONTAINER ID} ps -ef
# Current PHP version
docker exec {CONTAINER ID} php --version

# supervisord
## HELP
docker exec {CONTAINER ID} supervisorctl --help
## STOP, START, STATUS (stop/start/status)
docker exec {CONTAINER ID} supervisorctl stop all
## STOP NGINX / PHP
docker exec {CONTAINER ID} supervisorctl stop nginx/php-fpm

# Container not started
## PHP version
docker run --rm -it devcto/nginx-php:latest php --version

## NGINX version
docker run --rm -it devcto/nginx-php:latest nginx -v

Default

docker run -d -p 38080:80 \
devcto/nginx-php

http://docker.222029.xyz:38080


Custom website directory

docker run -d -p 38081:80 \
-v $(pwd)/wwwroot:/data/wwwroot \
devcto/nginx-php

http://docker.222029.xyz:38081


Bind the domain and the SSL certificate, make it to support HTTPS.

docker run -d -p 38082:80 \
-p 38083:443 \
-v $(pwd)/wwwroot:/data/wwwroot \
-v $(pwd)/wwwlogs:/data/wwwlogs \
-v $(pwd)/vhost:/usr/local/nginx/conf/vhost \
-v $(pwd)/ssl:/usr/local/nginx/conf/ssl \
devcto/nginx-php

http://docker.222029.xyz:38082
https://docker.222029.xyz:38083


Custom extension

docker run -d -p 38084:80 \
-v $(pwd)/wwwroot:/data/wwwroot \
-v $(pwd)/wwwlogs:/data/wwwlogs \
-v $(pwd)/extension.sh:/app/extension.sh \
devcto/nginx-php

Create a file extension.sh (you cannot change the file name),context as swoole

http://docker.222029.xyz:38084

Changelog