Nginx + php-fpm: permission denid

Hello,
I have nginx 1.6.2 (compiled from source) and php-fpm 5.5.9 on Ubuntu
server
14.04.1 LTS.
I have problem with php-fpm, I receive error 502 Bad Gateway.
In nginx error.log I found this:

2014/11/25 13:13:47 [crit] 5820#0: *29097 connect() to
unix:/var/run/php/php5-fpm.sock failed (13: Permission denied) while
connecting to upstream, client: 10.10.30.168, server: , request: “GET
/index.php HTTP/1.1”, upstream:
“fastcgi://unix:/var/run/php/php5-fpm.sock:”, host: “10.10.20.171:59000”

nginx.conf have these settings:

user www-data www-data;

server {
listen 10.10.20.171:59000;
location ~* .php$ {
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php/php5-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME
$fastcgi_script_name;
}

}

www.conf have these settings:

user = www-data
group = www-data
listen = /var/run/php/php5-fpm.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0664

Directory /var/run/php/ have www-data owner and these permission:

srw-rw-r-- 1 www-data www-data 0 Nov 25 12:01 php5-fpm.sock

with command “ps aux | grep -F -e php -e nginx” this is the result

root 5818 0.0 0.1 180148 2668 ? Ss 12:01 0:00 nginx:
master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
www-data 5819 5.4 4.4 592464 90568 ? Sl 12:01 4:03 nginx:
worker process
www-data 5820 6.8 4.9 599712 100984 ? Sl 12:01 5:04 nginx:
worker process
www-data 5821 5.4 4.5 595148 92560 ? Sl 12:01 4:02 nginx:
worker process
www-data 5822 6.3 4.4 595888 91696 ? Sl 12:01 4:40 nginx:
worker process
www-data 5823 0.0 0.3 189044 6724 ? Sl 12:01 0:00 nginx:
cache manager process
root 5853 0.0 0.6 133616 12596 ? Ss 12:01 0:00
php-fpm:
master process (/etc/php5/fpm/php-fpm.conf)
www-data 5855 0.0 0.1 133616 3720 ? S 12:01 0:00
php-fpm:
pool www
www-data 5856 0.0 0.1 133616 3720 ? S 12:01 0:00
php-fpm:
pool www
root 28003 0.0 0.0 11748 784 pts/0 R+ 13:15 0:00 grep
–color=auto -F -e php -e nginx

Can you help me ?
I need to use socket, not tcp. With tcp all works correctly.

Tnx
Manuel

Posted at Nginx Forum:

On Tue, Nov 25, 2014 at 07:16:52AM -0500, ManuelRighi wrote:

Hi there,

2014/11/25 13:13:47 [crit] 5820#0: *29097 connect() to
unix:/var/run/php/php5-fpm.sock failed (13: Permission denied)

Does

ls -lLdZ / /var /var/run /var/run/php

show why the user nginx runs as would be unable to get at the socket?

If not, are you running anything else which controls access to files? Do
logs for that give a hint?

f

Francis D. [email protected]

Hello,

I guess you have not the permission to create the socket.
My socket file look like:
srw-rw-rw- 1 www-data www-data 0 Nov 24 15:37 www.sock

Try to create this as root and set the permissions.

Check also user, group, listen.owner, listen.group and listen.mode in
your www.conf.
In history listen.mode was set to 0666 an update has change this to
0600, perhaps this is the error.

I hope this helps.

Regards,
Basti

Am 25.11.2014 13:16, schrieb ManuelRighi:

On Tue, Nov 25, 2014 at 9:48 PM, ManuelRighi [email protected]
wrote:

Hi,

drwxr-xr-x 24 root root ? 4096 Oct 26 14:07 /
drwxr-xr-x 17 root root ? 4096 Nov 25 09:59 /var
drwxr-xr-x 21 root root ? 900 Nov 25 13:48 /var/run
drw-rw-rw- 2 www-data www-data ? 60 Nov 25 13:47 /var/run/php

Accessing directory requires +x permission.

Hi,

drwxr-xr-x 24 root root ? 4096 Oct 26 14:07 /
drwxr-xr-x 17 root root ? 4096 Nov 25 09:59 /var
drwxr-xr-x 21 root root ? 900 Nov 25 13:48 /var/run
drw-rw-rw- 2 www-data www-data ? 60 Nov 25 13:47 /var/run/php

Posted at Nginx Forum:

Ok … I set 755 permission to directory /var/run/php and 660 to
php5-fpm.sock and now works :wink:

Tnx

Posted at Nginx Forum:

Hello,
I try to set permission to php5-fpm.sock file to 666 (srw-rw-rw- 1
www-data
www-data) but problem persist.
On www.conf I have listen.mode = 0660

Posted at Nginx Forum: