Home  >  Article  >  Backend Development  >  nginx-php5-fpm - Ubuntu14.04 安装nginx+php5-fpm 后访问php页面空白,怎么解决?

nginx-php5-fpm - Ubuntu14.04 安装nginx+php5-fpm 后访问php页面空白,怎么解决?

WBOY
WBOYOriginal
2016-06-06 20:36:19894browse

按网上的添加

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

还是无效,求解!

回复内容:

按网上的添加

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

还是无效,求解!

昨天刚刚折腾过这个,怒答一发:

首先确认 /etc/nginx/fastcgi_params 文件中是否有下面两行

<code>fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  PATH_INFO          $fastcgi_script_name;
</code>

然后查看你的nginx错误日志,如果是报的403错误:

确认nginx和php-fpm的运行用户

<code> ps aux | grep nginx
 ps aux | grep php-fpm
</code>

如果发现nginx中没有 www-data 用户的话就需要在nginx的配置文件中加入下面代码并重启(/etc/nginx/nginx.conf)

<code>user www-data www-data;
</code>

然后打开 /etc/php5/fpm/pool.d/www.conf 文件, 去掉下面三行的注释:

<code>listen.owner = www-data
listen.group = www-data
listen.mode = 0660
</code>

这就是我遇到的所有问题,你可以尝试一下,总之出问题先看日志,然后根据日志去解决问题,如果还没解决的话最好贴出你的日志来看看。

具体看下你机子上 php-fpm 是怎样运行的

ss --unix --all | grep php

依照上面命令的输出修改 配置文件中对应 server {} 中的 fastcgi_pass

其他参考 nginx - ArchWiki

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn