Permission Denied for fastcgi_pass using PHP7

Solution 1:

I got it working.

The php user was www-data but the nginx user was nginx.

Check php here: /etc/php/7.0/fpm/pool.d/www.conf

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

Nginx user was at /etc/nginx/nginx.conf

This guided me: https://stackoverflow.com/questions/23443398/nginx-error-connect-to-php5-fpm-sock-failed-13-permission-denied

Solution 2:

I have fixed same issue by taking following steps.

Open your www.conf files (Example : sudo nano /etc/php-fpm.d/www.conf) Lastly, find the lines that set the listen.owner and listen.group and change their values from "nobody" to "nginx":

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

Lastly, find the lines that set the user and group and change their values from "apache" to "nginx":

user = nginx
group = nginx

Restart php-fpm (sudo service php-fpm restart)


Solution 3:

vim /etc/php-fpm.d/www.conf
change in this way
;listen.owner = root
;listen.group = root
;listen.owner = nobody
;listen.group = nobody

listen.owner = nginx
listen.group = nginx 

service php-fpm restart
service nginx restart

CentOS release 6.9 (Final)

Tags:

Nginx

Php

Php7