Docker installation Nginx, PHP-FPM

Source: Internet
Author: User
Tags fpm docker run

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.