Operating Environment:
To create a directory:
Mkdir-p/users/sui/docker/nginx/conf.d && mkdir/users/sui/www && default
Start PHP-FPM:
Explain that PHP needs to be php-fpm and let it run first:
Docker run--name sui-php-d -v/users/sui/www:/var/www/html:ro php:7.1 -fpm--name sui-php is the name of the container. /users/sui/www is the directory where the local PHP files are stored,/var/www/html is the storage directory for PHP files within the container, and RO represents read-only.
To edit the Nginx configuration file:
#/users/sui/docker/nginx/conf.d/default. confserver {Listen the; server_name localhost; Location/{root/usr/share/nginx/html; Index index.html index.htm; } error_page - 502 503 504/50x.html; Location= /50x.html {root/usr/share/nginx/html; } Location~\.php$ {fastcgi_pass php:9000; Fastcgi_index index.php; Fastcgi_param Script_filename/var/www/html/$fastcgi _script_name; Include Fastcgi_params; }}
Description
php:9000 represents the access path to the PHP-FPM service, which is also mentioned below.
/var/www/html is the storage path of the PHP file in sui-php , which is mapped by Docker and becomes the local path/users/sui/www (you can take another look at the PHP-FPM start command
Start Nginx:
-- -d -v/users/sui/www:/usr/share/nginx/html:ro -v/users/sui/ docker/nginx/conf.d:/etc/nginx/conf.d:ro --link sui-php:php nginx
-P 80:80 is used to add port mappings, exposing 80 ports in the Sui-nginx .
/USERS/SUI/WWW is the storage directory for the local HTML file, and/usr/share/nginx/html is the storage directory for the HTML file inside the container.
/USERS/SUI/DOCKER/NGINX/CONF.D is the storage directory for the local nginx configuration file, and the/ETC/NGINX/CONF.D is the storage directory for the Nginx configuration file in the container.
--link sui-php:php put sui-php network into Sui-nginx, and by modifying Sui-nginx of/etc/hosts, the domain name php Mapped to 127.0.0.1, let Nginx access php-fpm through php:9000.
Test results:
Decentralization of two files in/users/sui/www: index.html index.php
Docker installation Nginx, PHP-FPM