我正在嘗試配置nginx。如果我輸入http://localhost/dav
,它應該在location /dav
指令中使用來自配置爲root
(c:/ wt-nmp/www/app-dav/frontend/web)的index.php
腳本。但是當我調試nginx時,它仍然使用配置爲server
配置的root
。更改不同請求上的nginx根
在調試,它看起來像:
- 它採用
location /dav
並設置root
新的價值和改變index.php?dav
- 現在使用
location ~ \.php$
但$document_root
仍指向c:/wt-nmp/www/m24/web
,但我認爲它應該改變在location /dav
正如第1點所述。
我的問題是如何配置nginx使用腳本從c:/wt-nmp/www/app-dav/frontend/web
當我輸入http://localhost/dav
。
我覺得這個代碼應該像那:
root
從server
指令當我輸入網址http://example.com/dav
然後指令location /dav
應該從該位置改變root
到.../m24/app-dav/frontend/web
和PHP腳本設置爲.../m24/web
- 應該執行。
- 但是,當我調試這個應用程序,腳本
.../m24/web
仍然執行。location /dav
爲什麼root
指令不會更改$document_root
值。$document_root
仍然指向.../m24/web
。
我的配置中最重要的部分是這樣的:
server {
...
root "c:/wt-nmp/www/m24/web";
index index.html index.htm index.php;
location /dav {
root "c:/wt-nmp/www/m24/app-dav/frontend/web";
# The $uri gets mangled by nginx, however Yii urlmanager requires REQUEST_URI to route
set $original_uri $uri?$args;
# Try the actual uri, then uri as a directory, then send it to yii
try_files $uri $uri/ /index.php?$args;
}
location/{
#set original_uri to use as the request_uri later on
#The $uri gets mangled by nginx, however Yii urlmanager requires REQUEST_URI to route
set $original_uri $uri?$args;
#Try the actual uri, then uri as a directory, then send it to yii
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_pass php_farm;
include nginx.fastcgi.conf;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param REQUEST_URI $original_uri;
}
}
你可以在得到這個更好的反應過[服務器故障(http://serverfault.com/)。 – DavidT 2014-09-26 10:07:48
完成。我應該刪除這個問題嗎? – marag 2014-09-26 11:34:41
海事組織其實並非這個網站的主題,只是想更多的人可以在SF上回答。 – DavidT 2014-09-26 11:46:31