【问题标题】:NginX & Munin - Location and error 404NginX 和 Munin - 位置和错误 404
【发布时间】:2012-11-23 02:09:24
【问题描述】:

我有一个运行 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;
  }
}

如何解决?非常感谢您的帮助

【问题讨论】:

    标签: nginx munin


    【解决方案1】:

    使用别名而不是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;
        }
    }   
    

    【讨论】:

      猜你喜欢
      • 2015-10-17
      • 2017-09-24
      • 2017-04-06
      • 1970-01-01
      • 2017-10-02
      • 2018-04-01
      • 2017-02-09
      • 2018-02-01
      • 2021-02-03
      相关资源
      最近更新 更多