nginx 在浏览器中可以html文件,但打开php文件就提示File not found.错误,即使存在php文件。出现这个错误是nginx.conf配置文件配置的问题。在nginx.conf配置文件中fastcgi进程接收了错误路径SCRIPT_FILENAME /scripts,导致文件未找到。
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
index index.php index.html;
}
解决方法:把fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;中的/scripts改成实际路径即可:
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
这个答案亲测是对的我在网上找了很多方法改了一个小时多才弄好。