Nginx serves .php downloads instead of executing

Why I download .php files instead of execute?

server {
listen 80;
server_name test.loc;

#access_log logs/host.access.log main;

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

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

location ~ \.php$ {
root /var/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
You need to add lines 20–27 to explain how to execute .php files

1st : add index.php in index

fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;

What Next?

Thank you for your attention

Senior web developer, architect, cryptocurrencies trader, https://lytvynov-anton.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store