我将nginx更新到1.4.7,将php更新到5.5.12,之后我得到了502错误。在我更新之前,一切都很好。

nginx-error.log

2014/05/03 13:27:41 [crit] 4202#0: *1 connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream, client: xx.xxx.xx.xx, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "xx.xx.xx.xx"

nginx.conf

user  www www;
worker_processes  1;

        location / {
            root   /usr/home/user/public_html;
            index  index.php index.html index.htm;
        }
        location ~ [^/]\.php(/|$) {
            fastcgi_split_path_info ^(.+?\.php)(/.*)$;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param  SCRIPT_FILENAME    /usr/home/user/public_html$fastcgi_script_name;
            include fastcgi_params;
        }

当前回答

如果你有声明

Pid = /run/php-fpm.pid

and

Listen = /run/php-fpm.pid

在不同的配置文件中,root将是该文件的所有者。

其他回答

这里目前提到的所有修复程序基本上都重新启用了安全漏洞。

我最后做的是将以下几行代码添加到我的PHP-FPM配置文件。

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

确保www-data是nginx worker实际运行的用户。对于debian,默认是www-data。

这样做并不会启用此更改应该修复的安全问题。

如果有的话,还必须考虑到您的个人FPM池。

我不明白为什么今天这些答案都对我不起作用。对我来说,这是一个设定后就忘记的场景,我已经忘记了倾听。用户和监听。组在每个池的基础上进行复制。

如果您像我一样为不同的用户帐户使用池,其中每个用户帐户拥有他们的FPM进程和套接字,只设置默认监听。拥有并倾听。“nginx”的组配置选项将根本不起作用。显然,让“nginx”拥有它们也是不可接受的。

对于每个池,请确保

listen.group = nginx

否则,您可以不考虑池的所有权等。

这里最重要的事情是,如果用户正在使用nginx,那么你也需要指定它

在nginx.conf中

user www-data;
worker_processes  1;

        location / {
            root   /usr/home/user/public_html;
            index  index.php index.html index.htm;
        }
        location ~ [^/]\.php(/|$) {
            fastcgi_split_path_info ^(.+?\.php)(/.*)$;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param  SCRIPT_FILENAME    /usr/home/user/public_html$fastcgi_script_name;
            include fastcgi_params;
        }

在你的www.conf

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

在你的例子中,用户和组是“www”,所以只需替换它。

重启nginx和PHP FPM

如果你有声明

Pid = /run/php-fpm.pid

and

Listen = /run/php-fpm.pid

在不同的配置文件中,root将是该文件的所有者。

请注意(至少在8分)你分配的用户在听。所有者和其他东西,它必须 与用户在同一个POOL中,例如我是foo用户

[www] # WRONG | IN MY CASE I WAS UNDER www POOL SO IT WASNT WORKING FOR ME.
[foo] # CORRECT | THE POOL AND THE USER MATCHES.

listen.owner = foo
listen.group = foo
listen.mode = 0660
user = foo
group = foo

我不知道是否有一个全球性的游泳池,但经过几个小时的搜索,我终于做到了。