Skip to content

Instantly share code, notes, and snippets.

@zhangludi
Created May 20, 2019 08:22
Show Gist options
  • Save zhangludi/17e3ed8a2480edbe2925b8bccf64c4e8 to your computer and use it in GitHub Desktop.
Save zhangludi/17e3ed8a2480edbe2925b8bccf64c4e8 to your computer and use it in GitHub Desktop.
docker nginx 虚拟机
server {
listen 80;
server_name www.zlmm.cc; # 虚拟机域名
root /usr/share/nginx/html/zlmm;
index index.php index.html index.htm;
#charset koi8-r;
access_log /dev/null;
#access_log /var/log/nginx/nginx.localhost.access.log main;
error_log /var/log/nginx/nginx.localhost.error.log warn;
#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 /usr/share/nginx/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 / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
location ~ \.php$ {
root html;
fastcgi_pass 172.17.0.2:9000;#此处需要填写你的php容器的docker内部通讯ip
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
docker cp /data/www.zlmm.conf lnmp:/etc/nginx/conf.d/www.zlmm.conf
docker restart lnmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment