nginx error connect to php5-fpm.sock failed (13: Permission denied)

后端 未结 25 1844
悲哀的现实
悲哀的现实 2020-11-27 09:12

I update nginx to 1.4.7 and php to 5.5.12, After that I got the 502 error. Before I update everything works fine.

25条回答
  •  南方客
    南方客 (楼主)
    2020-11-27 09:38

    @Xander's solution works, but does not persist after a reboot.

    I found that I had to change listen.mode to 0660 in /etc/php5/fpm/pool.d/www.conf.

    Sample from 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. 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-data
    ;listen.group = www-data
    ;listen.mode = 0660
    

    Edit: Per @Chris Burgess, I've changed this to the more secure method.

    I removed the comment for listen.mode, .group and .owner:

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

    /var/run Only holds information about the running system since last boot, e.g., currently logged-in users and running daemons. (http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard#Directory_structure).

    Side note:

    My php5-fpm -v Reports: PHP 5.4.28-1+deb.sury.org~precise+1. The issue did happen after a recent update as well.

提交回复
热议问题