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.

Here's part of config in the server block:

I was unable to execute any php script , I placed a file named test.php under /var/html , but when I point to http://localhost/test.php , I got a result:

File not found.,

That's not generated by nginx , since it's different from the 404 page of nginx.

location / {
    root   /var/html;
    index  index.html index.htm;
}

    location ~ \.php$ {
        fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index  index.php; 
        fastcgi_intercept_errors on;
        fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
        fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
        include        fastcgi.conf;
    }

Did I miss anything ?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

You're defining the document root under the / location, and this doesn't apply to the \.php$ location. Move the root directive outside the / location so that it is applied to both.

root   /var/html;
location / {
    index  index.html index.htm;
}
location ~ \.php$ {
    ...
}
share|improve this answer
    
Root inside locations is bad, by the way. (Relevant to question, not the answer). –  Dmitry Verkhoturov May 22 '12 at 12:13

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.