Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a simple nginx setup and things work fine.

I have set the index as follows:

index index.html index.php

The server_name is set to local.nginx. If i request http://local.nginx it works fine, but if i request http://local.nginx/index.php - the raw file is sent to the browser.

What is wrong?

Please see my config below:

server {
    listen       80;
    server_name  local.nginx;
    root         /var/www/local.nginx/;
    index       index.html index.php;

    location ~ \.php$ {
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;


I discovered this was only happening in chrome. After clearing the browser cache the problem disappeared. Can anyone explain what happened here ?

share|improve this question
up vote 3 down vote accepted

If while testing, your PHP configuration was not working, Chrome will have cached the raw .php file and continued to serve that.

Please be careful with your PHP configuration, especially if you'll be accepting uploads or saving any input to files in the document root, as it's possible to add path info to a url and get the PHP interpreter to execute it, e.g.


share|improve this answer
How do you prevent that with the configuration then? (the issue with the path)? – Marty Wallace Feb 17 '13 at 21:40
Assuming everything is running on the same box, then you can add this into that location block: try_files $uri =404; This will check if the file exists and if not return a 404. – Alan Feb 17 '13 at 21:45

Your Answer


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.