Nginx 502 bad getway error connect to php5-fpm.sock failed (13: Permission denied)

今天做了系统更新之后打开页面出现了 502 BAD GETWAY ,打开日志显示:

[crit] 2332#0: *681 connect() to unix:/tmp/php-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 104.224.169.175, server: xxx.xxx.com, request: “GET /p.php HTTP/1.1”, upstream: “fastcgi://unix:/tmp/php-fpm.sock:”, host: “xxx.xxx.com”

这是由于权限不足导致的,没法使用.sock 文件进行解析PHP,如果我们手动设置/tmp/php-fpm.sock设置成777权限就可以打开了。

下面我们只需要修改一下配置文件,一劳永逸的方法,下次不需要手动修改权限:

vi /etc/php-fpm.d/www.conf

将下面3行之前的分号删除,变成如下内容即可:

listen.owner = www-data
listen.group = www-data
listen.mode = 0660

重启php-fpm:

/etc/init.d/php-fpm restart

如果页面能正常打开表示搞定。


评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注