前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Nginx新手配置$document_root

Nginx新手配置$document_root

作者头像
星哥玩云
发布2022-07-26 21:01:49
2.1K0
发布2022-07-26 21:01:49
举报
文章被收录于专栏:开源部署开源部署

Nginx新手配置$document_root

nginx配置php老是出错,最后才发现是$document_root的设置问题。

 location ~ \.php$ {     root        html;     fastcgi_pass  127.0.0.1:9000;     fastcgi_index  index.php;     fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;     include        fastcgi_params;  }

用这个出现找不到php的错误。

因为$document_root 的参数是由root html那一行定义的,默认是在/usr/share/nginx/html/ 所以把 html换成站点根目录就正常了。

# vi /etc/nginx/conf.d/default.confbak server {     listen      80;     server_name  localhost;

    #charset koi8-r;     #access_log  /var/log/nginx/host.access.log  main;

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

    #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 ~ \.php$ {         root          /usr/share/nginx/html;         fastcgi_pass  127.0.0.1:9000;         fastcgi_index  index.php;         fastcgi_param  SCRIPT_FILENAME  $document_root$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;     #} }

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档