Nginx throws 404 only on php scripts using php-fpm

Solved it. It turns out that the problem was the permissions set on the socket where php was listening. I just had to change a directive called listen.mode on /etc/php-fpm.d/www.conf

listen.mode = 0750

And set the user to nginx:

listen.owner = nginx
listen.group = nginx

So the file looks like this:

srwxr-x---. 1 nginx nginx 0 jul  8 08:59 /var/run/php5-fpm.sock

Because I was using a unix socket instead of a tcp port:

listen = /var/run/php5-fpm.sock;

Also, I was getting 404 instead of 500 or 503 because my www.conf was configured to redirect errors to custom pages, and since they weren't there, I was getting 404's.

Edit:

It appears that in most recent versions of the nginx distribution in Fedora (Fedora 22, 23), nginx uses the apache user by default, and the socket is set to the user apache too, so no further configuration is needed.

Tags:

Nginx

Php Fpm