php-fpm and nginx : file not found

GlinesMome asked:

I have a very common but annoying error, the classical : “File not found”.
I have the following nginx.conf :

server {
    listen 80;
    server_name aperophp;

    root /home/gline/mysite/web;

    location = / {
        try_files @site @site;

    location / {
        try_files $uri $uri/ @site;

    location ~ \.php$ {
        return 404;

    location @site {
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME $document_root/index.php;
        fastcgi_param  PATH_INFO $fastcgi_script_name;

But I have this file :

$ ls -ld /home/gline/mysite/web/index.php 
-rw------- 1 gline gline 66 Jan  5 13:25 /home/gline/mysite/web/index.php

If you have some idea.

For your help,
Thanks by advance.

My answer:

Your file is not readable by the PHP process.

You can see that the permissions on the script permit only the user gline to read (or write) to the file, but PHP by default runs under a different user ID (e.g. nobody or www-data).

To resolve the issue, make the file world readable. You may also need to make the containing directory and its parent directories searchable.

chmod a+r /home/gline/mysite/web/index.php
chmod a+x /home/gline/mysite/web
chmod a+x /home/gline/mysite
chmod a+x /home/gline

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.