[英]Unable to access PHP files sitting outside the document root of an nginx site
我有一個基於CodeIgniter構建的PHP應用程序。 我在文檔根目錄下有很大一部分網站(對任何知道CodeIgniter的人來說都是系統文件夾)。
這是該網站的Nginx conf
server {
server_name www.domain.local;
root /var/www/html/domain/frontend;
include /etc/nginx/conf.d/ci_vhost;
}
這是我嘗試訪問/var/www/html/ci/2.0.2/system
時遇到的文件夾
使用Apache,我從來沒有遇到訪問文檔根目錄下的php文件的問題。
有誰知道為什么我在Nginx上遇到這個問題?
謝謝。
您可以訪問服務器上的任何文件夾,而只需使用“ alias”或“ root”指令相應地配置nginx,這兩個指令都可以在特定塊中多次定義。
server {
# Default root
root /var/www/html/domain/frontend;
location /abc
# Uses default root
...
}
location /xyz
# defines it's own root
root /var/www/some/folder;
...
}
location /123
# aliases to another folder
alias /etc/some/folder;
...
}
location /
# Uses default root
...
}
}
對於php,您將不得不考慮open_basedir限制。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.