Docker installed PHP + Nginx

Install Nginx

docker pull nginx

Installing PHP

docker pull php:7.3.5-fpm

 

Start PHP-FPM

docker run --name myphpfpm -v /data/ftp:/www -d php:7.3.5-fpm

 / Data / FTP  external path   www  is docker mapping path in the

 

Nginx configuration file

server {
    listen       80;
    server_name  localhost;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm index.php;
    }

    error_page   500 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  /www/$fastcgi_script_name;
        include        fastcgi_params;
    }
}

Profile Description:

  • PHP: 9000 : represents the URL php-fpm services, we will specify below.
  • / WWW / : is the storage path myphpfpm php file mapped to the local ~ / nginx / www directory.

 

Start Nginx

docker run --name php_nginx -p 8089:80 -d -v /data/ftp:/user/share/nginx/html:ro -v /data/nginx/conf/conf.d:/etc/nginx/conf.d:ro --link myphpfpm:php nginx

 

  • 8089 -p: 80 : port mapping, the  nginx  80 8089 mapped to the local port.
  • / Data / FTP : a local html file storage directory, / usr / share / nginx / html html file directory is stored in the container.
  • /data/conf/conf.d : is a local storage directory nginx configuration file, / etc / nginx / conf.d directory is stored within the container nginx profile.
  • myphpfpm --link: php : the myphpfpm network incorporated in  nginx , and by modifying the  nginx  's / etc / hosts, the domain name  php  mapped to 127.0.0.1, so that by nginx php: 9000 Access php-fpm.
  • ro for read-only

 

Guess you like

Origin www.cnblogs.com/jso0/p/10956781.html