docker run --name nginxphp -p 80:80 -d -v /www:/usr/share/nginx/html:ro -v /usr/local/docker/nginx/conf/conf.d:/etc/nginx/conf.d:ro -v /usr/local/docker/nginx/logs:/var/log/nginx --link myphp-fpm:php nginx:1.20
docker run --name myphp-fpm -v /www:/var/www/html -d php:5.6-fpm
备注: /www 为宿主机
ngxin 配置文件 xx.conf //所在目录 /usr/local/docker/nginx/conf/conf.d
server {
listen80;
server_name localhost,127.0.0.1 ;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/share/nginx/html/www.xxxxxxx.com; //这里路径是ngxin 容器的
index index.php index.html index.htm;
}
location ~ \.php?.*$ {
root /usr/share/nginx/html/www.xxxxxxx.com; //这里路径是ngxin 容器的
index index.php index.html index.htm;
fastcgi_pass 172.17.0.2:9000; //这里ip 写php容器ip
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html/www.xxxxxxx.com$fastcgi_script_name;//这里的路径 是 php容器的。
include fastcgi_params;
}
#error_page 404/404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# roothtml;
# fastcgi_pass 172.17.0.2:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# includefastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}