Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 {
        fastcgi_pass  127.0.0.1:9000;
        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.

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

You should check that php-fpm can read this php file, check if you have

 user = gline
 group = gline

in your php-fpm conf file regarding pool.

share|improve this answer
add comment

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
share|improve this answer
add comment

Lot of odd things going on in this conf.

It's returning 404, because you're telling it to. Anything ending in .php will match the location ~ \.php$ block.

Also, why do you have the two / location blocks?

It's hard to tell what you're trying to achieve from the conf file, but this is a pretty standard nginx/php conf:

server {
    listen 80;
    server_name aperophp;

    root /home/gline/mysite/web;

    location / {
        try_files $uri $uri/ @rewrite;
    }

    location @rewrite {
        rewrite ^/(.*)$ /index.php?q=$1;
    }

    location ~ \.php$ {
        fastcgi_pass  127.0.0.1:9000;
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param  PATH_INFO $fastcgi_script_name;
    } 
}
share|improve this answer
    
Thanks for your help, but I have a 403 instead, even if index.php and its parent directory have a 0777 chmod. 2013/02/21 16:37:46 [error] 6402#0: *1 directory index of "/home/gline/mysite/web/" is forbidden, client: 127.0.0.1, server: aperophp, request: "GET / HTTP/1.1", host: "aperophp" –  GlinesMome Feb 21 '13 at 15:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.