如何配置Munin-2.0.x在Fedora上用CGI(仅)生成内容?

net*_*ama 7 apache fastcgi fedora apache2 munin

我有一个400+节点munin-1.4.x安装,我想升级到munin-2.x,以利用munin主服务器上基于CGI的内容生成(html和图形).我已经浏览了官方的dox(http://munin-monitoring.org/wiki/CgiHowto2),它根本就没用了.它只涵盖VirtualHost(http://munin.example.com),这不是我的设置,但我试图用它作为起点.

具体来说,我希望http://example.com/munin成为动态生成列出所有节点的html内容的基本URL,其中包含指向各个节点页面的链接(然后在单击时动态生成/更新) .增加的问题是我在Fedora上做了这个(16),而我发现的绝大多数的howto都假设Debian/Ubuntu(或假设通过cron生成非cgi静态内容).

官方的Fedora munin软件包安装如下:

  • munin基目录是/ var/www/html/munin
  • munin静态内容direcotry是/ var/www/html/munin/static
  • munin cgi脚本(munin-cg-graph&munin-cg-html)位于/ var/www/html/munin/cgi

到目前为止我做了什么:*在/etc/munin/munin.conf中设置"html_strategy cgi"和"cgiurl_graph/munin/cgi/munin-cgi-html"*在/ etc/httpd/conf/httpd中添加了以下内容.conf文件:

# Rewrites
RewriteEngine On
Alias /static /var/www/html/munin/static
Alias /munin /var/www/html/munin
# HTML
RewriteCond %{REQUEST_URI} !^/static
RewriteCond %{REQUEST_URI} .html$ [or]
RewriteCond %{REQUEST_URI} =/
RewriteRule ^/(.*)           /var/www/html/munin/cgi/munin-cgi-html/$1 [L]
# Images
# - remove path to munin-cgi-graph, if present
RewriteRule ^/munin/cgi/munin-cgi-graph/(.*) /$1
RewriteCond %{REQUEST_URI}                 !^/static
RewriteCond %{REQUEST_URI}                 .png$
RewriteRule ^/(.*)  /var/www/html/munin/cgi/munin-cgi-graph/$1 [L]
ScriptAlias /munin/cgi/munin-cgi-graph   /var/www/html/munin/cgi/munin-cgi-graph
<Location /munin/cgi/munin-cgi-graph>
        Options +ExecCGI FollowSymLinks
        <IfModule mod_fcgid.c>
                SetHandler fcgi-script
        </IfModule>
        <IfModule !mod_fcgid.c>
                SetHandler cgi-script
        </IfModule>
</Location>
ScriptAlias /munin/cgi/munin-cgi-html   /var/www/html/munin/cgi/munin-cgi-html
<Location /munin/cgi/munin-cgi-html>
        Options +ExecCGI FollowSymLinks
        <IfModule mod_fcgid.c>
                SetHandler fcgi-script
        </IfModule>
        <IfModule !mod_fcgid.c>
                SetHandler cgi-script
        </IfModule>
</Location>
Run Code Online (Sandbox Code Playgroud)

但是,在完成所有操作(并重新启动apache)之后,当我访问http://example.com/munin时,我收到404错误,并在apache错误日志中看到:

File does not exist: /var/www/html/munin/cgi/munin-cgi-html/munin/index.html
Run Code Online (Sandbox Code Playgroud)

我希望我只是遗漏了一些明显的东西,但是现在我完全不知道还有什么可能需要调整来使这项工作.谢谢.

jhw*_*ist 1

问题是,如果您在基于“位置”的设置(而不是在“虚拟主机”)中使用配置,则 RewriteRule 的标志是错误的。

根据mod_rewrite文档:

 L  Stop the rewriting process immediately and don't apply any more rules.
Run Code Online (Sandbox Code Playgroud)

但是,在您的情况下,您希望传递 /munin/cgi/munin-cgi-html ,以便 ScriptAlias 实际触发。因此:

 PT Forces the resulting URI to be passed back to the URL mapping engine for
    processing of other URI-to-filename translators, such as Alias or Redirect
Run Code Online (Sandbox Code Playgroud)

如果您更改阅读规则

RewriteRule ^/(.*)  /munin/cgi/munin-cgi-html/$1 [PT]  
....  
RewriteRule ^/(.*)  /munin/cgi/munin-cgi-graph/$1 [PT]
Run Code Online (Sandbox Code Playgroud)

请注意相对路径,否则 ScriptAlias 将不起作用。