小生博客:http://xsboke.blog.51cto.com
-------谢谢您的参考,如有疑问,欢迎交流
- 环境
php-5.6.36
nginx-1.14.0 - 问题
访问php测试文件时报404(文件不存在),已经确认权限和配置都没有问题。 - 处理过程
查看nginx错误日志:报如下错误(172.16.6.236是服务器)2018/08/03 01:05:34 [error] 57141#0: *242 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 172.16.6.237, server: localhost, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "172.16.6.236"
- 解决过程
在nginx官网查看有没有类似错误,发现没有,然后百度。。。。(笑哭)
解决办法如下,
将:#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
修改为:fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; #fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
解释:
$document_root 就是nginx配置项“root”指定的位置参数的变量
转载于:https://blog.51cto.com/xsboke/2153734