PHP site is downloading

Asked

Viewed 3,090 times

1

I was trying to configure the serverblocks (vhost) of Nginx, 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 code?

How to recover this setting?

1 answer

1

As Vinicius remarked, the estate Location stays inside server. As answered in that matter soen,

  1. 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;
        }
    }
    
  2. Edit /etc/php5/fpm/php.ini and set the value of cgi.fix_pathinfo for 0.

  3. Restart Nginx and php5.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.