访问php文件,不能解析或直接下载,nginx.conf中如下配置不正确或未配置
userwwwwww;
index index.phpindex.htmlindex.htm;
#
pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#取消FastCGI
server部分location的注释,注意fastcgi_param行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径
location~\.php${
roothtml;
fastcgi_pass127.0.0.1:9000;
fastcgi_indexindex.php;
fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;
includefastcgi_params;
}
访问php文件,nginx对PHP文件报File not found 错误
错误原因:配置文件 nginx.conf 中
userwwwwww;
index index.phpindex.htmlindex.htm;
#
pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#取消FastCGI
server部分location的注释,注意fastcgi_param行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径
location~\.php${
roothtml;
fastcgi_pass127.0.0.1:9000;
fastcgi_indexindex.php;
fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;
includefastcgi_params;
}
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
改成如下这句,即可
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
本文介绍了解决Nginx无法正确处理PHP请求的问题。通过调整配置文件中的location块及fastcgi参数设置,确保Nginx能正确地将PHP请求传递给FastCGI服务器。
2755

被折叠的 条评论
为什么被折叠?



