1
我在爲yii2基本應用程序配置nginx服務器時遇到了問題。Nginx Yii2在不同文件夾中的配置
這裏是我的服務塊文件:
server {
listen 80 ;
access_log /var/log/nginx/access-server.log;
error_log /var/log/nginx/error-server.log;
charset utf-8;
location /fetch {
root /usr/share/nginx/html/another_folder/web/;
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
我的項目位於另一個文件夾 「another_folder」。 而我希望當用戶轉到url:http://ip/fetch文件nginx將提供來自另一個文件夾的文件。
我的錯誤日誌文件返回我:
2017/02/11 12:38:52 [error] 4242#0: *12 FastCGI sent in stderr: "Unable to open primary script: /usr/share/nginx/html/index.php (No such file or directory)" while reading response header from upstream
與兄顯示: 沒有指定輸入文件。
你能幫我解決這個問題嗎?
謝謝!
你想讓'/ fetch/index.php'位於'/ usr/share/nginx/html/another_folder/web/index.php或'/ usr/share/nginx/html/other_folder/web /讀取/ index.php'? –
在此文件夾中:/usr/share/nginx/html/another_folder/web/index.php – Farkhad
您需要使用'alias'指令。見[這個答案](http://stackoverflow.com/questions/42137658/nginx-forwarding-few-localhosts-to-php-fpm/42138410#42138410)。 –