NginX&;穆宁-位置和错误404

NginX&;穆宁-位置和错误404,nginx,munin,Nginx,Munin,我有一台运行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;

我有一台运行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/I时,我收到一个404错误(当我请求ipoftheserver/var/www/default/public_html上的文件被正确侦听)

Munin已经安装好,工作正常。如果删除此配置并使用另一个配置,则所有配置都可以正常工作(但不在/munin/目录中):


如何修复?非常感谢您的帮助

使用别名而不是root解决问题

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;
    }
}   
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;
    }
}