Website in PHP is downloading

1

I was trying to configure nginx's serverblocks (vhost), so I deleted the default file located in /etc/nginx/sites-enabled/default and created a file with the name of my site, added these lines below:

 server {
    listen   80;
    root /usr/share/nginx/html;
    index index.php index.html index.htm;

    # Make site accessible from http://localhost/
    server_name http://localhost/;
}

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
}

And now my site which is in PHP, tested on my server, when I open it, it downloads! I think some line of code that was in the "default" file had something to interpret PHP codes?

How to recover this setting?

    
asked by anonymous 01.10.2015 / 01:04

1 answer

1

As Vinicius commented, the location property is within server . As answered in this issue of SOen,

  • Change your code to:

    server {
        listen   80;
        root /usr/share/nginx/html;
        index index.php index.html index.htm;
    
        # Make site accessible from http://localhost/
        server_name localhost;
    
        location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
        }
    }
    
  • Edit the /etc/php5/fpm/php.ini and set the cgi.fix_pathinfo value to 0 .

  • >
  • Restart nginx and php5.

  • 01.10.2015 / 14:05