NGINX不执行PHP文件

我无法find答案。 安装了PHP5 + NGINX + PHP-FPM并且不能执行php文件,它会得到一个“哎呀!这个链接似乎被打破了。 CHROME错误。 我没有任何有价值的错误日志报告,我有一个index.php根目录,试图创build一个自定义phpinfo.php文件,都没有工作。

我可以加载HTML文件,但不能PHP。

这是我在NGINX的本地站点configuration:

server { listen 80; server_name im; access_log /var/www/website/access.log; error_log /var/www/website/error.log; location / { root /var/www/website; index index.html index.htm index.php; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/website$fastcgi_script_name; include /etc/nginx/fastcgi_params; } } 

将所有目录的所有权更改为www-data:www-data,在php文件中创build了777,没有任何内容。 重启nginx,FPM,什么都没有。

帮帮我? 🙁

它会得到一个“哎呀!这个链接似乎被打破了。” CHROME错误。

如果错误页面小于512字节,Chrome会显示自己的错误页面。

我怀疑你在fastcgi_params有以下行:

 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 

如果是这样,因为root指令定义在location /将永远不会应用到location ~ \.php$ ,因此SCRIPT_FILENAME成为URI。

这可以通过将root指令移动到server级别上下文来解决:

 server { listen 80; server_name im; access_log /var/www/website/access.log; error_log /var/www/website/error.log; root /var/www/website; location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } 
  fastcgi_pass unix:/var/run/php5-fpm.sock;