Ubuntu + php-fpm + nginx + unix socket = 13:权限被拒绝

i can't make work nginx with php-fpm. Googled whole day, tried everything but no result.

Any request is 502 and in error log i see this:

# tail /var/log/**/*error*.log
==> /var/log/nginx/acme.www.error.log <==
2016/08/16 04:24:14 [crit] 930#930: *1 connect() to unix:/root/.phpbrew/php/php-5.6.24/var/run/php-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 10.0.2.2, server: acme.dev, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/root/.phpbrew/php/php-5.6.24/var/run/php-fpm.sock:", host: "www.acme.dev:8080"

More tech info about my configuration here (it's almost default from repos):

# uname -a
Linux vagrant-ubuntu-trusty-64 3.13.0-93-generic #140-Ubuntu SMP Mon Jul 18 21:21:05 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

# php -v
PHP 5.6.24 (cli) (built: Aug 16 2016 02:28:22)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Xdebug v2.4.1, Copyright (c) 2002-2016, by Derick Rethans

# phpbrew fpm which
/root/.phpbrew/php/php-5.6.24/sbin/php-fpm

# /root/.phpbrew/php/php-5.6.24/sbin/php-fpm -v
PHP 5.6.24 (fpm-fcgi) (built: Aug 16 2016 02:28:29)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Xdebug v2.4.1, Copyright (c) 2002-2016, by Derick Rethans

# /root/.phpbrew/php/php-5.6.24/sbin/php-fpm -t
[16-Aug-2016 04:09:42] NOTICE: configuration file /root/.phpbrew/php/php-5.6.24/etc/php-fpm.conf test is successful

# cat /root/.phpbrew/php/php-5.6.24/etc/php-fpm.conf | egrep 'user|owner|group|mode'
user = www-data
group = www-data
listen.owner = www-data
listen.group = www-data
listen.mode = 0660

# nginx -v
nginx version: nginx/1.10.1

# cat /etc/nginx/nginx.conf | egrep 'user|owner|group|mode'
user www-data;

# cat /etc/nginx/snippets/fastcgi-php.conf | grep fastcgi_pass
fastcgi_pass unix:/root/.phpbrew/php/php-5.6.24/var/run/php-fpm.sock;
# fastcgi_pass unix:/root/.phpbrew/php/php-7.0.9/var/run/php-fpm.sock;

# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

# date +%Y-%m-%d\ %H:%M:%S
2016-08-16 04:21:21

# ls -ahlFG /root/.phpbrew/php/php-5.6.24/var/run/php-fpm.sock
srw-rw---- 1 www-data 0 Aug 16 04:02 /root/.phpbrew/php/php-5.6.24/var/run/php-fpm.sock=

# getfacl /root/.phpbrew/php/php-5.6.24/var/run/php-fpm.sock
getfacl: Removing leading '/' from absolute path names
# file: root/.phpbrew/php/php-5.6.24/var/run/php-fpm.sock
# owner: www-data
# group: www-data
user::rw-
group::rw-
other::---

# groups nginx
nginx : nginx www-data

# groups www-data
www-data : www-data nginx

# ps aux | grep -F -e php -e nginx
root      2660  0.0  0.1  91500  1596 ?        Ss   03:57   0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data  2661  0.1  0.3  92200  3612 ?        SN   03:57   0:02 nginx: worker process
www-data  2662  0.0  0.3  92200  3120 ?        SN   03:57   0:00 nginx: worker process
www-data  2664  0.1  0.3  92200  3612 ?        SN   03:57   0:02 nginx: worker process
root      2712  0.0  1.0 251288 10276 ?        Ss   04:02   0:00 php-fpm: master process (/root/.phpbrew/php/php-5.6.24/etc/php-fpm.conf)
www-data  2713  0.0  0.9 251288  9216 ?        S    04:02   0:00 php-fpm: pool www
www-data  2714  0.0  0.9 251288  9216 ?        S    04:02   0:00 php-fpm: pool www
root      3101  0.0  0.0  11920   788 pts/0    R+   04:20   0:00 grep --color=auto -F -e php -e nginx

I'm lost with this and even don't know how to search where is error.

With php-7.0.9 – same error.

douzi6060
douzi6060 是的,从/root移动到/运行解决问题-我不知道为什么phpbrew的全局安装就是这样的。谢谢!你可以写答案,我会批准它。
大约 4 年之前 回复
douli8040
douli8040 套接字文件/root/.phpbrew/php/php-5.6.24/var/run/php-fpm.sock可能由www-data拥有,但用户www-data甚至可能无法进入父文件夹,如果嘿他们没有+x。
大约 4 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐