2012-08-16 102 views
1

我有一個純HTML網站。現在我必須添加一個包含PHP文件的子目錄(演示)。我將在我的nginx.conf文件中的兩個位置:Nginx與PHP在一個子目錄中

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?我試過不同的組合,但沒有任何作品。任何幫助,將不勝感激!

回答

2

很可能您的fastcgi_param應該是/www$fastcgi_script_name,因爲變量是完整的URI請求。 Source

+0

它的工作原理!非常感謝。 – Yang 2012-08-16 15:20:39