Activities

March 2010
M T W T F S S
« Feb   Apr »
1234567
891011121314
15161718192021
22232425262728
293031  

Installing Nagios on WHM/Cpanel servers

How do I install nagios on WHM/Cpanel loaded with Centos ?

I spent about 5 hours to find a solution for viewing nagios web interface since cpanel is using SuPhp bind with Apache. I’ve done the nagios installation so quickly but cpanel apache config. didn’t allow to include “conf.d” folders in “include” list. obviously this command wont work.
#make install-webconf
When I’m trying to access the nagios after adding it on the include file which cpanel says, I got an error like this and page doesn’t visible.

<strong>root@server8-28-25-132 [~]# vi /usr/local/apache/logs/suphp_log</strong>

[Mon Mar 15 09:48:18 2010] [warn] File “/usr/local/nagios/share/index.php” is writeable by group
[Mon Mar 15 09:53:30 2010] [warn] Mismatch between target UID (99) and UID (32007) of file “/usr/local/nagios/share/index.php”

So neither of my attempts were note worked yet. It’s something caused suphp. After Googling I didn’t get a scenario exact same like this but causd me to have get some tweaks :-).

The idea is I create a new subdomain ( nagios.test.com) on Cpanel and modified the values written by the Cpanel on Apache.

My new value is,

<strong><virtualHost 82.22.25.12:80>
ServerName nagios.test.com
ServerAlias www.nagios.test.com
DocumentRoot /home/test/public_html/nagios
ServerAdmin webmaster@test.com
UseCanonicalName On
CustomLog /usr/local/apache/domlogs/nagios.test.com combined
CustomLog /usr/local/apache/domlogs/nagios.test.com-bytes_log “%{%s}t %I .n%{%s}t %O .”
## User test # Needed for Cpanel::ApacheConf
SuPHP_UserGroup nagios nagios
SuexecUserGroup nagios nagios
<ifModule mod_suphp.c>
suPHP_UserGroup  nagios nagios
</ifModule>
<ifModule !mod_disable_suexec.c>
SuexecUserGroup nagios nagios
</ifModule>
ScriptAlias /nagios/cgi-bin “/usr/local/nagios/sbin”
<directory “/usr/local/nagios/sbin”>
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName “Nagios Access”
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</directory>
Alias /nagios “/usr/local/nagios/share”
<directory “/usr/local/nagios/share”>
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName “Nagios Access”
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</directory>
</virtualHost>   </strong>

Pls note the line ” suPHP_UserGroup nagios nagios”.

Then restart the webserver

#apachectl restart

Now I can see the Nagios web interface nicely at last. The url is http://nagios.test.com/nagios. That’s worked 😀

I have tweaked my previous post again. (do not try this, Sometimes this may brake Apache-php extension )

There is another easier method to done. Basic idea is create a conf file and add the nagios Apache entries on and include it on Apache main file rather than editing that file itself.

For doing this first I made the “include” file entry on main config. file.
#vi /etc/httpd/conf/httpd.conf and include the line on my domain virtual host part.
Include “/home/myuser/conf/nagios.conf”

#vi /home/myuser/conf/nagios.conf and add the following line in it.

suPHP_UserGroup nagios nagios
SuexecUserGroup nagios nagios
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
Alias /nagios "/usr/local/nagios/share"
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
 
Then restart the apache

#apachectl restart

Making chages permently on httpd.conf in an WHM Apache server
#/usr/local/cpanel/bin/apache_conf_distiller -–update
root@server88-20-25-12 [~]# /usr/local/cpanel/bin/apache_conf_distiller –update
Distilled successfully
root@server88-20-25-12 [~]#

Pls note that all the custom entry on the “http.conf” will be over written by apache on next config. generation. So the better idea is identify the “include” directory entry in your virtual host. Then create a link to your conf. file from that location.

you will see the similar link as follows,

Include “/usr/local/apache/conf/userdata/*.conf”
Include “/usr/local/apache/conf/userdata/std/*.conf”
Include “/usr/local/apache/conf/userdata/std/2/*.conf”
Include “/usr/local/apache/conf/userdata/std/2/myuser/*.conf”

here I chose “usr/local/apache/conf/userdata” location to place my conf.file
#cd usr/local/apache/conf/userdata
# ln -s /home/myuser/conf/nagios.conf nagios.conf
#apachectl configtest
#/usr/local/cpanel/bin/apache_conf_distiller –update
#/usr/local/cpanel/bin/build_apache_conf

NB: This entry will be over written by Apache on next “httpd.conf” build and we will lost this entry.  I didn’t find any fix for that.
That’s it

8 comments to Installing Nagios on WHM/Cpanel servers

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>