加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

NginX和Munin-位置和错误404

发布时间:2020-12-13 20:53:02 所属栏目:Nginx 来源:网络整理
导读:我有一个使用以下简单配置运行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; inde

我有一个使用以下简单配置运行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;
  }
}

怎么修?非常感谢您的帮助

最佳答案
使用别名而不是根来解决

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读