I have a website in pure HTML. Now I have to add a sub-directory (demo) containing PHP files. I set up two locations in my nginx.conf file:
server {
listen 80;
server_name mydomain.com;
access_log /mydomain.com/access.log;
location / {
root /www;
index index.html index.htm;
}
location /demo {
root /www/demo;
index /demo/index.php;
}
location ~ /demo/.*\.php$ {
root /www/demo;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www/demo$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
Now the mydomain.com works just fine, but when I try to access mydomain.com/demo/, it keeps complaining
No input file specified.
What's the problem with this script? I guess some path is not correctly setup like fastcgi_index: should it be /demo/index.php? I've tried different combinations but none works. Any help would be appreciated!
It's likely that your
fastcgi_param
should be/www$fastcgi_script_name
because the variable is the full URI request. Source.