Docker install Nginx and PHP

Source: Internet
Author: User
Tags php server docker cp docker run

Reference article: https://www.cnblogs.com/boundless-sky/p/7182410.html

1. Download the image
Docker Pull Nginx
Docker Pull PHP:7.2.4-FPM

2. Make a nginx configuration file: Run a container and delete the container after default.conf.
Docker run--name mynginx_test-d-P 28369:80 nginx
Docker CP mynginx_test:/etc/nginx/conf.d/default.conf./default.conf
Docker Stop Mynginx_test
Docker RM mynginx_test

3. Preparing the Environment
Copy the above default.conf to/home/wyt/docker_data/nginx, and then modify the contents:
Location/{
root/usr/share/nginx/html;
Index index.html index.htm index.php;
}

Location ~ \.php$ {
Fastcgi_pass php:9000;
Fastcgi_index index.php;
Fastcgi_param script_filename/var/www/html/$fastcgi _script_name;
Include Fastcgi_params;
}
Prepare/home/wyt/docker_data/www to store Web pages

4. Running the container
Docker run--name myphp-d-v/home/wyt/docker_data/www:/var/www/html php:7.2.4-fpm
Docker run--name mynginx-d-P 80:80-v/home/wyt/docker_data/www:/usr/share/nginx/html \
-V/HOME/WYT/DOCKER_DATA/NGINX:/ETC/NGINX/CONF.D--link myphp:php Nginx


5. Testing
Put 2 test files in/home/wyt/docker_data/www index.html and test/index.php

6. Description
Default.conf inside php:9000 means to find the PHP server in the DNS, and the back link is to put it into the DNS resolution

Docker install Nginx and PHP

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.