我剛剛在 ubuntu 12.04 LTS 上安裝了 nginx。當我訪問本地主機時,它給了我:
500 內部伺服器錯誤 nginx/1.2.3
error_log 有以下內容
重寫或內部重定向循環,同時內部重定向到“/index.html”,客戶端:127.0.0.1,伺服器:localhost,請求:“GET / HTTP/1.1”,主機:“localhost”
這是預設的 nginx 設定:nginx.conf 有:
include /etc/nginx/sites-enabled/*;
/etc/nginx/sites-enabled/default 有以下內容
root /usr/share/nginx/www;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.html;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
答案1
Nginx 將預設網站名稱直接從 www 變更為 html。
根 /usr/share/nginx/www;
應該改為
根/usr/share/nginx/html;
答案2
對於這個簡單的配置,您根本不需要 location 區塊和 try_files。