3

この単純な構成で nginx+php-fpm を実行しているサーバーがあります。

server {
    listen   80;
    server_name ipoftheserver;
    access_log /var/www/default/logs/access.log;
    error_log /var/www/default/logs/error.log;

    location / {
        root   /var/www/default/public_html;
        index  index.html index.htm index.php;
    }


    location ^~ /munin/ {
        root /var/cache/munin/www/;
        index index.html index.htm index.php;
    }

    location ~\.php$ {
    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /var/www/default/public_html$fastcgi_script_name;
    }
}

しかし、ipoftheserver/munin/ を開くと 404 エラーが表示されます (ipoftheserver/ を要求すると、/var/www/default/public_html のファイルが正しくリッスンされます)。

Munin がインストールされ、完全に動作します。この構成を削除して別の構成を使用すると、すべて正常に動作します (ただし、/munin/ ディレクトリにはありません):

server {
  server_name ipoftheserver;
  root /var/cache/munin/www/;
  location / {
    index index.html;
    access_log off;
  }
}

直し方?助けてくれて本当にありがとうございます

4

1 に答える 1

3

ルートの代わりにエイリアスを使用して解決

server {
    listen   80;
    server_name ipoftheserver;
    access_log /var/www/default/logs/access.log;
    error_log /var/www/default/logs/error.log;

    location / {
        root   /var/www/default/public_html;
        index  index.html index.htm index.php;
    }


    location /munin/ {
        alias /var/cache/munin/www/;
        index index.html index.htm index.php;
    }

    location ~\.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME /var/www/default/public_html$fastcgi_script_name;
    }
}   
于 2012-11-22T14:51:09.797 に答える