在一个子目录中使用php的Nginx

在一个子目录中使用php的Nginx,php,nginx,Php,Nginx,我有一个纯HTML的网站。现在我必须添加包含PHP文件的子目录(演示)。我在nginx.conf文件中设置了两个位置: server { listen 80; server_name mydomain.com; access_log /mydomain.com/access.log; location / { root /www; index index.html i

我有一个纯HTML的网站。现在我必须添加包含PHP文件的子目录(演示)。我在nginx.conf文件中设置了两个位置:

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;
    }
}
现在mydomain.com工作正常,但当我尝试访问mydomain.com/demo/时,它总是抱怨

No input file specified.

这个脚本有什么问题?我猜有些路径设置不正确,比如fastcgi_index:应该是/demo/index.php吗?我尝试过不同的组合,但没有一种有效。任何帮助都将不胜感激

您的
fastcgi_参数
可能应该是
/www$fastcgi_script_name
,因为变量是完整的URI请求