0
点赞
收藏
分享

微信扫一扫

如何正确使用$_SERVER[‘DOCUMENT_ROOT’]识别该路径的文件


php的$_SERVER[‘DOCUMENT_ROOT’] 跟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那一行定义的,默认是在/etc/nginx/html/ 所以把 html换成站点根目录就正常了。

举报

相关推荐

0 条评论