關於 location 的問題, 我的nginx配置如下
server {
listen 80;
server_name localhost;
charset utf-8;
root /usr/local/nginx/html;
location /mobiletest {
alias /usr/local/nginx/html/test/;
index index.php;
}
location / {
alias /usr/local/nginx/html/;
index index.php index.html index.htm;
}
location ~ .*\.php$ {
fastcgi_pass 127.0.0.1:5000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_intercept_errors on;
} }
當我測試 127.0.0.1/test.php php會正常解析沒有問題
但當我執行 127.0.0.1/mobiletest/test.php 會出現error
錯誤訊息是 FastCGI sent in stderr: "Primary script unknown"
while reading response header from upstream
php無法正常被解析
之後我又修改了配置
location /mobiletest {
alias /usr/local/nginx/html/test/;
index index.php;
location ~ .*\.php$ {
fastcgi_pass 127.0.0.1:5000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_intercept_errors on;
} }
修改後還是會出現相同的錯誤, 請問要如何配置才會正常呢?
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.248.221.203
※ 文章網址: https://www.ptt.cc/bbs/Linux/M.1499959364.A.A71.html
※ 編輯: herbacin (111.248.221.203), 07/13/2017 23:22:54
※ 編輯: herbacin (111.248.221.203), 07/13/2017 23:23:36
※ 編輯: herbacin (111.248.221.203), 07/13/2017 23:37:22
→
07/14 00:58, , 1F
07/14 00:58, 1F

→
07/14 00:59, , 2F
07/14 00:59, 2F
→
07/14 01:00, , 3F
07/14 01:00, 3F
推
07/14 03:28, , 4F
07/14 03:28, 4F
→
07/14 07:53, , 5F
07/14 07:53, 5F
→
07/14 08:13, , 6F
07/14 08:13, 6F
→
07/14 08:14, , 7F
07/14 08:14, 7F
※ 編輯: herbacin (223.140.220.26), 07/14/2017 09:58:42
→
07/15 21:05, , 8F
07/15 21:05, 8F
→
07/15 21:05, , 9F
07/15 21:05, 9F
→
07/16 00:43, , 10F
07/16 00:43, 10F
→
07/16 00:44, , 11F
07/16 00:44, 11F
→
07/16 00:51, , 12F
07/16 00:51, 12F
※ 編輯: herbacin (111.248.208.151), 07/16/2017 00:51:53
→
07/16 04:15, , 13F
07/16 04:15, 13F
→
07/16 04:21, , 14F
07/16 04:21, 14F
→
07/16 04:21, , 15F
07/16 04:21, 15F
→
07/16 05:59, , 16F
07/16 05:59, 16F
→
07/16 06:00, , 17F
07/16 06:00, 17F
→
07/16 12:54, , 18F
07/16 12:54, 18F
→
07/16 12:54, , 19F
07/16 12:54, 19F
→
07/16 12:59, , 20F
07/16 12:59, 20F
→
07/16 12:59, , 21F
07/16 12:59, 21F