简体   繁体   English

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

[英]how to configure Munin-2.0.x to generate content with CGI (only) on Fedora?

I've got a 400+ node munin-1.4.x installation, that I'd like to upgrade to munin-2.x, to take advantage of the CGI based content generation (html & graphs) on the munin master server. 我有一个400+节点munin-1.4.x安装,我想升级到munin-2.x,以利用munin主服务器上基于CGI的内容生成(html和图形)。 I've gone through the official dox ( http://munin-monitoring.org/wiki/CgiHowto2 ), and its simply not working. 我已经浏览了官方的dox( http://munin-monitoring.org/wiki/CgiHowto2 ),它根本就没用了。 It only covers a VirtualHost ( http://munin.example.com ), which is not my setup, but I tried to use it as a starting point. 它只涵盖VirtualHost( http://munin.example.com ),这不是我的设置,但我尝试将其作为起点。

Specifically, I want & need http://example.com/munin to be the base URL that dynamically generates the html content listing all the nodes, with links to the individual node pages (which are then dynamically generated/updated when clicked upon). 具体来说,我希望http://example.com/munin成为动态生成列出所有节点的html内容的基本URL,其中包含指向各个节点页面的链接(然后在单击时动态生成/更新) 。 The added catch is that I'm doing this on Fedora(16), and the vast majority of howto's that I've found assume Debian/Ubuntu (or assume non-cgi static content generation via cron). 增加的问题是我在Fedora上做了这个(16),而我发现的绝大多数的howto都假设Debian / Ubuntu(或假设通过cron生成非cgi静态内容)。

The official Fedora munin package installs the following: 官方的Fedora munin软件包安装如下:

  • munin base directory is /var/www/html/munin munin基目录是/ var / www / html / munin
  • munin static content direcotry is /var/www/html/munin/static munin静态内容direcotry是/ var / www / html / munin / static
  • munin cgi scripts (munin-cg-graph & munin-cg-html) are in /var/www/html/munin/cgi munin cgi脚本(munin-cg-graph&munin-cg-html)位于/ var / www / html / munin / cgi

What I've done so far: * set "html_strategy cgi" and "cgiurl_graph /munin/cgi/munin-cgi-html" in /etc/munin/munin.conf * Added the following to /etc/httpd/conf/httpd.conf: 到目前为止我做了什么:*在/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>

However, after doing all that (and restarting apache), when I go to http://example.com/munin , I get a 404 error, and in the apache error log I see: 但是,在完成所有操作(并重新启动apache)后,当我访问http://example.com/munin时 ,我收到404错误,并在apache错误日志中看到:

File does not exist: /var/www/html/munin/cgi/munin-cgi-html/munin/index.html

I'm hoping that i'm just missing something obvious, but right now I'm at a complete loss on what else might need to be adjusted to make this work. 我希望我只是遗漏了一些显而易见的东西,但是现在我完全不知道还有什么可能需要调整以使其发挥作用。 thanks. 谢谢。

The problem is that, if you use the configuration in a "location" based setup (rather than in a VirtualHost"), the flag for the RewriteRule is wrong. 问题是,如果您在基于“位置”的设置(而不是在VirtualHost中)中使用配置,则RewriteRule的标志是错误的。

As per mod_rewrite docu: 根据mod_rewrite docu:

 L  Stop the rewriting process immediately and don't apply any more rules.

However, in your case you want /munin/cgi/munin-cgi-html to be passed on so that the ScriptAlias actually triggers. 但是,在您的情况下,您希望传递/ munin / cgi / munin-cgi-html,以便ScriptAlias实际触发。 Thus: 从而:

 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

If you change your rules to read 如果您更改规则以阅读

RewriteRule ^/(.*)  /munin/cgi/munin-cgi-html/$1 [PT]  
....  
RewriteRule ^/(.*)  /munin/cgi/munin-cgi-graph/$1 [PT]

Note the relative path, as otherwise the ScriptAlias doesn't work. 请注意相对路径,否则ScriptAlias不起作用。

I had exactly the same problem and I struggled for a while, but I eventually came up with the following config which should do exactly what you want. 我有完全相同的问题,我挣扎了一段时间,但我最终想出了以下配置,它应该完全符合你的要求。

My system is Ubuntu Server 12.10. 我的系统是Ubuntu Server 12.10。 For some reasons my static files are located at /var/cache/munin/www, I'm not sure whether this is standard on Ubuntu or it was caused by my recent upgrade from Ubuntu 12.04. 由于某些原因,我的静态文件位于/ var / cache / munin / www,我不确定这是否是Ubuntu的标准版,或者是我最近从Ubuntu 12.04升级引起的。

    RewriteEngine On

    # HTML
    RewriteRule ^/munin/(.*\.html)?$ /munin/munin-cgi/munin-cgi-html/$1 [PT]

    # Images
    RewriteRule ^/munin/munin-cgi/munin-cgi-graph/(.*) /munin/$1
    RewriteCond %{REQUEST_URI} !^/static
    RewriteRule ^/munin/(.*.png)$ /munin/munin-cgi/munin-cgi-graph/$1 [L,PT]

    <Directory /var/cache/munin/www/>
            Order deny,allow
            Allow from all
    </Directory>

    # Ensure we can run (fast)cgi scripts
    ScriptAlias /munin/munin-cgi/munin-cgi-graph /usr/lib/cgi-bin/munin-cgi-graph
    <Location /munin/munin-cgi/munin-cgi-graph>
            Options +ExecCGI
            SetHandler fcgid-script
            Allow from all
    </Location>

    ScriptAlias /munin/munin-cgi/munin-cgi-html /usr/lib/cgi-bin/munin-cgi-html
    <Location /munin/munin-cgi/munin-cgi-html>
            Options +ExecCGI
            SetHandler fcgid-script
            Allow from all
    </Location>

Ensure munin-cgi is installed and the dependencies: mod_fcgid. 确保安装了munin-cgi和依赖项:mod_fcgid。

CentOS 7, no special parameters added to the file configuration located at /etc/httpd/conf.d/munin.conf. CentOS 7,没有为/etc/httpd/conf.d/munin.conf中的文件配置添加特殊参数。

Regards. 问候。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM