Docker-nginx + PHP-FPM Development environment

Source: Internet
Author: User
Tags fpm docker ps docker cp docker run

Download image
docker pull nginxdocker pull bitnami/php-fpm
Environment configuration

Build your development environment in the physical organization configuration directory and Nginx configuration files, easy to manage.

Building containers
docker run --name myFpm  -v /Users/zhen/www-root/work:/usr/share/nginx/html -v /Users/zhen/docker/lnmp/nginx:/etc/nginx/conf.d -d bitnami/php-fpmdocker run --name myNginx -p 80:80  -v /Users/zhen/www-root/work:/usr/share/nginx/html -v /Users/zhen/docker/lnmp/nginx:/etc/nginx/conf.d -d nginx

Although all normal but still cannot access through the physical machine, view the IP information, found the problem. To modify the Nginx configuration.

docker inspect myFpm | grep "IPAddress"docker inspect myNginx | grep "IPAddress"

server {    listen 80;    server_name  xxxx.com xxxxx.com xxxx.com    index index.html index.htm index.php;    root /usr/share/nginx/html/mhadmin;        #access_log /tmp/mhadmin.log;    #error_log /tmp/mhadmin_error.log error;        location / {        index  index.php index.html;        try_files $uri $uri/ /index.php?$query_string;        if (!-e $request_filename) {            rewrite ^(.*)$ /index.php?s=$1 last;            break;        }    }    location ~ \.php {        fastcgi_pass   172.17.0.2:9000;         fastcgi_index  index.php;        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;        include        fastcgi_params;    }    location ~ /\.ht {        deny  all;    }}修改fastcgi_pass   127.0.0.1:9000; 为:fastcgi_pass   172.17.0.2:9000;

Get.

Common commands

Enter the container

docker exec -it myNginx /bin/bash

To replicate the configuration within the container to the host machine

docker cp myNginx:/etc/nginx/conf.d/default.conf ./default.conf

Copy host machine files to container

docker cp ./default.conf myNginx:/etc/nginx/conf.d/default.conf

Nginx Reload Configuration

service nginx reload

Stop all containers

docker stop $(docker ps -a -q)

Remove all containers

docker rm $(docker ps -a -q)

Docker-nginx + PHP-FPM Development environment

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.