Nginx的/ FPM / PHP所有的PHP文件说'文件没有find。

我刚安装了CentOS 5.8最后的64位机器上的nginx 1.1.13和php 5.4.0。 Nginx和PHP / Fpm正在运行,我可以通过ssh命令行运行php脚本,但是在浏览器中我总是收到'找不到文件'。 所有的PHP文件错误。

这是我如何让我的nginx.conf处理PHP脚本:

location ~ \.php$ { root /opt/nginx/html; fastcgi_pass unix:/tmp/fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /opt/nginx/html$fastcgi_script_name; include fastcgi_params; } 

这是从我的其他服务器的直接复制/粘贴,在这个设置工作正常(但他们运行旧版本的PHP / FPM)。

为什么我会收到这些错误?

把“包含fastcgi_params;” 在所有“fastcgi_param *”行之前,“include fastcgi_params;” 覆盖你所有的“fastcgi_param *”行(参见nginxdebugging日志):

 location ~ \.php$ { root /opt/nginx/html; fastcgi_pass unix:/tmp/fpm.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME /opt/nginx/html$fastcgi_script_name; } 

我遇到过同样的问题。

我所做的解决这个问题的方法是检查用户运行nginx,php-fpm并检查他们访问根目录所在文件夹的权限。 这是默认的“www-data”。

但是可以通过使用ps aux | grep php-fpm ps aux | grep php-fpmps aux | grep nginx ps aux | grep nginx命令。

您必须确保运行这些进程的用户可以访问该文件夹。

我有同样的问题,对我来说,这是在Nginx服务器configuration错误configuration/不存在的“根”指令

我使用这样的configuration,希望它可以帮助你。 它适用于OS X.至于我,@ Xosofox的答案工作。 我打错了1.2.6版本的nginx 1.6.2,所以根目录变成了一个不存在的目录。

 location ~ \.php$ { fastcgi_intercept_errors on; root /usr/local/Cellar/nginx/1.6.2/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME /usr/local/Cellar/nginx/1.6.2/html$fastcgi_script_name; } 

我通过更改php-fpm.d / http://www.conf中的当前用户:组来更改用户和组来解决此问题

默认情况下,用户和组是'nginx',改变这….

希望这可以帮助