Ubuntu に Nginx をインストールすると 500 エラーが発生する

Ubuntu に Nginx をインストールすると 500 エラーが発生する

Ubuntu 12.04 LTS に nginx をインストールしました。localhost にアクセスすると、次のメッセージが表示されます:

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 はまったく必要ありません。

関連情報