码迷,mamicode.com
首页 > 其他好文 > 详细

502 Bad Gateway(Nginx) 查看nginx日志有如下内容

时间:2016-09-01 11:00:54      阅读:342      评论:0      收藏:0      [点我收藏+]

标签:

2016/09/01 09:49:41 [error] 79464#79464: *3 user "nagios" was not found in "/usr/local/nagios/etc/htpasswd.users", client: 192.168.1.209, server: localhost, request: "GET / HTTP/1.1", host: "192.168.1.5"
2016/09/01 09:49:45 [error] 79464#79464: *3 user "nagios" was not found in "/usr/local/nagios/etc/htpasswd.users", client: 192.168.1.209, server: localhost, request: "GET / HTTP/1.1", host: "192.168.1.5"
2016/09/01 09:49:51 [crit] 79464#79464: *3 connect() to unix:/tmp/phpfpm.sock failed (13: Permission denied) while connecting to upstream, client: 192.168.1.209, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/tmp/phpfpm.sock:", host: "192.168.1.5"
2016/09/01 09:49:51 [error] 79464#79464: *3 open() "/usr/local/nagios/share/favicon.ico" failed (2: No such file or directory), client: 192.168.1.209, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "192.168.1.5"
2016/09/01 09:49:51 [error] 79464#79464: *3 open() "/usr/local/nagios/share/favicon.ico" failed (2: No such file or directory), client: 192.168.1.209, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "192.168.1.5"

 

前面两个是因为密码不对

第二个说是connect() to unix:/tmp/phpfpm.sock failed  重点是:(13: Permission denied)

后面的错误是因为受到[crit]的影响而来的

这里呢,上次碰到过一次,不过也弄了好久,

这一次有点印象,就很容易找到原因,并且修改回来


 

开始修改文件了--------------------------

[root@dep5 ~]# vim /usr/local/php/etc/php-fpm.conf

查找phpfpm.sock这一向,发现这个sock在/tmp下面,

[root@dep5 ~]# ll /tmp/phpfpm.sock
srw-rw---- 1 root root 0 9月   1 08:30 /tmp/phpfpm.sock

发现phpfpm.scok的属主属组都是root用户,并且权限为660

而且源码安装PHP和Nginx指定的用户是daemon,daemon,根本没权限查看和修改这个sock文件

 

解决一方案:

vim /usr/local/php/etc/php-fpm.conf

查找下面那两个

 

; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
;                 mode is set to 0660

listen.owner=****

listen.group=****

将那listen.owner和listen.group注释取消掉,并且改成nginx用户

或者

将 ;listen.mode = 0660 注释取消的,直接改成777得了(^_^)
解决方案二:

chmod 777 /tmp/phpfpm.sock  

#PS:我没试过这个方案,但觉得可行,但是这里还有个问题,当把php-fpm重启的时候,权限又被自己改回来了,。。。。。

 

502 Bad Gateway(Nginx) 查看nginx日志有如下内容

标签:

原文地址:http://www.cnblogs.com/losbyday/p/5828646.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!