我将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;
        }

当前回答

-还检查linux (/etc/ SELINUX):

# getenforce

关掉它:

# setenforce 0

其他回答

如果你有声明

Pid = /run/php-fpm.pid

and

Listen = /run/php-fpm.pid

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

简单但有效。

listen.owner = nginx
listen.group = nginx

chown nginx:nginx /var/run/php-fpm/php-fpm.sock

我确实在我的服务器上更换了好几次操作系统,试图获得最舒适的系统。

它曾经工作得很好,大部分时间,但最后我得到了这个502网关错误。

我为每个帐户使用一个php fpm套接字,而不是为所有帐户保留同一个套接字。因此,如果一个应用程序崩溃,至少其他应用程序可以继续运行。

我以前有用户和组www-data。但这在我的Debian 8上发生了变化,使用了最新的Nginx 1.8和php5-fpm。

默认用户为nginx,组为nginx。为了确保这一点,最好的方法是检查/etc/group和/etc/passwd文件。这些是不会说谎的。

它是在那里,我发现现在我有nginx在两者和不再www-data。

也许这可以帮助那些仍然试图找出错误消息不断出现的原因的人。

这对我很管用。

在这里:

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

但这里也要改变:

; When set, listen.owner and listen.group are ignored
listen.acl_users = apache
;listen.acl_groups =

注释这一行:

; When set, listen.owner and listen.group are ignored
;listen.acl_users = apache
;listen.acl_groups =

我想对那些尝试了所有方法但仍然卡住的人说:这解决了我的问题。 我更新了/usr/local/nginx/conf/nginx.conf

取消标注user的行 把它改成www-data,这样它就变成:user www-data; 保存它(需要根权限) 重启nginx