twn39 / code

:memo: 代码笔记,通过 issue 的方式记录日常遇到的问题和学习笔记
13 stars 1 forks source link

CentOS openresty php-fpm 使用unix sock链接 #115

Open twn39 opened 8 years ago

twn39 commented 8 years ago

在CentOS 中使用openresty 和 php-fpm, 配置php-fpm以unix sock连接,一直报403或者404错误。 开启openresty错误日志,查看日志发现:

 connect() to unix:/var/run/php7-fpm.sock failed (13: Permission denied) 

/var/run/php7-fpm.sock更改权限

sudo chmod 777 /var/run/php7-fpm.sock

注: 报错原因是在www.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.
; Default Values: user and group are set as the running user
;                 mode is set to 0660
;listen.owner = nobody
;listen.group = nobody
;listen.mode = 0660

去掉注释即可

twn39 commented 8 years ago

其中/var/run/php7-fpm.sock在php配置文件路径:/etc/php-fpm.d/www.conf