码迷,mamicode.com
首页 > Web开发 > 详细

nginx连接php-fpm sock文件失败502

时间:2014-12-18 15:35:53      阅读:523      评论:0      收藏:0      [点我收藏+]

标签:ar   io   使用   for   on   文件   问题   bs   cti   

今天把vps上php5.3升级到了php5.4,我采用的是nginx+php-fpm的架构,nginx通过php-fpm的socks文件来连接。
结果报错:
connect() to unix:/tmp/php-cgi.sock failed (13: Permission denied) while connecting to upstream

我检查了一下 /tmp/php-cgi.sock 发现该文件拥有者是root,而nginx和php-fpm都是www用户来运行的,按理讲,这个sock文件也应该是www才对。

后来发现在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 = www
;listen.group = www
;listen.mode = 0660

很奇怪,按照说明,默认应该使用 user和group配置项来设置权限,但实际上没有。不管怎么样,通过手动指定一下这里的配置就解决问题了。
; 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 = www
listen.group = www
;listen.mode = 0660

nginx连接php-fpm sock文件失败502

标签:ar   io   使用   for   on   文件   问题   bs   cti   

原文地址:http://my.oschina.net/cxz001/blog/357589

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