I have configured php-fpm, and nginx for development under a home folder, and I've been unable to resolve a permissions issue. It appears that php7.1-fpm.sock still refuses a connection, even though all permissions appear to be correct.
Error:
root@xps:/var/log/nginx# cat error.log
2017/05/29 00:41:23 [crit] 27326#27326: *1 connect() to unix:/run/php/php7.1-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 127.0.0.1, server: sub.tld.com, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.1-fpm.sock:", host: "sub.tld.com"
This occurs every time I attempt to access the web root, which should display:
<?php echo phpinfo(); ?>
in a browser window.
nginx.conf
user darin darin;
[...]
sub.tld.com.conf for nginx
server_name sub.tld.com
root /home/darin/www
[...]
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
www.conf for php-fpm
user = darin
group = darin
[...]
listen = /run/php/php7.1-fpm.sock
[...]
listen.owner = darin
listen.group = darin
listen.mode = 0660
[...]
It appears that /run/php is a symbolic link to /var/run/php. Maybe this is intended to simplify configuration. I'm not sure, but pointing the socket file to /var/run/php and /run/php should work.
root@xps:/etc/nginx/conf.d# ls -l /var/run/php/
total 4
-rw-r--r-- 1 root root 4 May 29 14:33 php7.1-fpm.pid
srw-rw---- 1 darin darin 0 May 29 14:33 php7.1-fpm.sock
root@xps:/etc/nginx/conf.d# ls -l /run/php/
total 4
-rw-r--r-- 1 root root 4 May 29 14:33 php7.1-fpm.pid
srw-rw---- 1 darin darin 0 May 29 14:33 php7.1-fpm.sock
nginx processes
ps aux | grep nginx
root 5489 0.0 0.0 31884 880 ? Ss 14:33 0:00 nginx:
master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
darin 5490 0.0 0.0 32308 3536 ? S 14:33 0:00 nginx: worker process
fpm processes
ps aux | grep fpm
root 5535 0.0 0.7 642880 60172 ? Ss 14:33 0:00 php-fpm: master process (/etc/php/7.1/fpm/php-fpm.conf)
darin 5537 0.0 0.1 642880 12472 ? S 14:33 0:00 php-fpm: pool www
darin 5563 0.0 0.1 642880 12472 ? S 14:33 0:00 php-fpm: pool www
I read loads of configuration posts, and the configuration files appear to be correct. There was one post that indicated I needed to change permissions of /var/lib/nginx, so darin:darin owns this, but I do not find a /var/lib/nginx file or folder.