Nginx failed to connect to the php-fpmsock file 502 today I upgraded php5.3 on vps to php5.4. I used the nginx + php-fpm architecture, and nginx connected through the socks file of php-fpm.
Error:
Connect () to unix:/tmp/php-cgi.sock failed (13: Permission denied) while connecting to upstream
I checked/tmp/php-cgi.sock and found that the file owner is root, and nginx and php-fpm are run by www users, this sock file should also be available at www.
It is found that there is such a configuration in the 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. requests
; 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
It is strange that, according to the instructions, the user and group configuration items should be used by default to set permissions, but actually no. In any case, manually specify the configuration here to solve the problem.
; 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. requests
; 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