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

nginx server is downloading the php files instead of executing them

I tried every solution that has been posted around web

most of the people had problem with location

but mine is uncommented already

my default conf file

server {
    #listen   80; ## listen for ipv4; this line is default and implied
    #listen   [::]:80 default ipv6only=on; ## listen for ipv6

    root /usr/share/nginx/www;
    index index.php index.html index.htm;

    # Make site accessible from http://localhost/

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to index.html
            try_files $uri $uri/ /index.html;
            # Uncomment to enable naxsi on this location
            # include /etc/nginx/naxsi.rules

    location /doc/ {
            alias /usr/share/doc/;
            autoindex on;
            deny all;

    # Only for nginx-naxsi : process denied requests
    #location /RequestDenied {
            # For example, return an error code
            #return 418;

    error_page 404 /404.html;

    # pass the PHP scripts to FastCGI server listening on

    location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
    #       # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
    #       # With php5-cgi alone:
    #       fastcgi_pass;
    #       # With php5-fpm:
            try_files $uri =404;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #location ~ /\.ht {
    #       deny all;
share|improve this question
That looks fine. What example of a URL is failing? – Michael Hampton Mar 12 '14 at 22:10 or is failing – user19212 Mar 12 '14 at 22:12
What's wrong with that URL? – Michael Hampton Mar 12 '14 at 22:13
Nothing is wrong.i dont know why nginx is downloading files.. do you think is it beacuse of php5-fpm or fastcgi ? if it is how can i check ? – user19212 Mar 12 '14 at 22:14
No it isn't, it gives me the login form as it seems to be intended to do. Did you do something silly like fail to clear your browser cache? – Michael Hampton Mar 12 '14 at 22:19

Your Answer


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

Browse other questions tagged or ask your own question.