I am using below configuration settings but it is downloading index source file on execution. But it is showing output of index.html if it is put instead of index.php
Overall it seems it is not reading php file.
server {
server_name test.com;
root /var/www/test;
index index.html index.php;
# serve static files directly
location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
expires max;
}
location / {
# Check if a file or directory index file exists, else route it to index.php.
try_files $uri $uri/ /index.php;
}
location ~ /\.ht {
deny all;
}
}
You must setup the PHP-FPM or fastcgi, if not you will get the plain file:
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /var/www/test/index.php;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_pass_header Host;
fastcgi_pass_header X-Real-IP;
include /etc/nginx/fastcgi_params;
And PHP-FPM should be running in port 9000