Docker容器配置之Nginx+Php
阿新 • • 發佈:2019-01-01
#############################Php docker pull php:5.6-fpm mkdir -p /usr/local/docker/php/www #Php 原始碼目錄 mkdir -p /usr/local/docker/php/conf #Php 配置目錄,如果php配置不需要改動,可以不講其引入容器中 mkdir -p /usr/local/docker/php/logs vim /usr/local/docker/php/www/index.php <?php PHPinfo(); echo PHP_VERSION; ?> #Nginx會轉發到Php-fpm的本地目錄www下 docker run -d -p 9001:9000 --name php-fpm \ -v /usr/local/docker/php/www:/www \ -v /usr/local/docker/php/logs:/phplogs \ php:5.6-fpm ############################Nginx docker pull nginx mkdir -p /usr/local/docker/nginx/conf #配置目錄 mkdir -p /usr/local/docker/nginx/html #原始碼目錄 mkdir -p /usr/local/docker/nginx/logs vim /usr/local/docker/nginx/conf/ng.conf server { listen 80; server_name localhost; index index.html index.php; access_log /var/log/nginx/access.log; location / { root /var/www/html; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location ~ \.php$ { root /www; fastcgi_pass 192.168.10.80:9001; #指定本機IP:php-Port fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include /etc/nginx/fastcgi_params; } } vim /usr/local/docker/nginx/html/index.html <html> <body> <font size="40px" color="red"> Local_Host_Ip: 192.168.10.80</br> Nginx_Inside_Port: 80</br> Nginx_Outside_Port: 85</br> Php_Inside_Port: 9000</br> Php_Outside_Port: 9001</br> </br> </body> </html> docker run -d -p 85:80 --name nginx \ -v /usr/local/docker/nginx/conf:/etc/nginx/conf.d \ -v /usr/local/docker/nginx/logs:/var/log/nginx \ -v /usr/local/docker/nginx/html:/var/www/html \ nginx