Archive for June, 2012

Nagios Installation on FreeBSD-9.0

Posted in FreeBSD on June 19, 2012 by kiranopatil

Nagios installation on FreeBSD-9.0

 

Install Mysql Server 5.5 from ports

 # cd /usr/ports/databases/mysql55-server

# make

# make install clean

 
 

To start mysql service, Add the below line to /etc/rc.conf

mysql_enable=”YES”

# ee /etc/rc.conf

Start mysql server using below mentioned command

#/usr/local/etc/rc.d/mysql-server start

Make mysql admin password

Set the mysql admin password as “nagios”

# mysqladmin -u root -p password nagios

(mysqladmin -u root password “newpassword”)

Log in to mysql console to check if the password was set proprely using below mentioned command

# mysql –u root –p

Type the password

You can exit from the prompt by typing “exit” command

Install  Apache  from ports

# cd /usr/ports/www/apache22

# make

# make install clean

Enable mysql-support in the blue screen

Enable and launch the apache service

Add the below line to /etc/rc.conf

apache22_enable=”YES”

# ee /etc/rc.conf

Start Apache service:

# /usr/local/etc/rc.d/apache22 start

Test the apache page http://ip or http://hostname

Install  PHP and  php-extention

# cd /usr/ports/lang/php52

# make

# make install clean

Make sure to enable apache module in the install Step (Blue screen)

# cd /usr/ports/lang/php52-extensions

# make

# make install clean

Select sessions and mysql support in the configurations options (Blue screen)

Php Configuration

Settings for PHP are stored in the /usr/local/etc/php.ini file.

Use the following command

# cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini

Also Apache needs to be configured, so it can use php.

# cd /usr/local/etc/apache22/

# ee httpd.conf

Scroll down to the end of the /usr/local/etc/apache22/httpd.conf and add the following lines.

DirectoryIndex index.php index.html index.htm

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

Save and exit.

Test PHP

Restart   apache  to check if  you  have  any  errors

# /usr/local/etc/rc.d/apache22 restart

Output:

Performing sanity check on apache22 configuration:

Syntax OK

Stopping apache22.

Waiting for PIDS: 61539.

Performing sanity check on apache22 configuration:

Syntax OK

Starting apache22.

Check  phpinfo page

To test the php run the following command to create a php file in the


# echo “<? phpinfo(); ?>” >> /usr/local/www/apache22/data/test.php

Now check the page http://ip/test.php

Install Nagios:

# cd /usr/ports/net-mgmt/nagios

# make

# make install clean

And use default installation, in installation screen of nagios plugins don’t forget to add NETSNMP to Nagios group and user.

Enable nagios  to  start  with  boot

Add the below line to /etc/rc.conf

nagios_enable=”YES”

# ee /etc/rc.conf

Now copy the sample page to the configuration files

# cd /usr/local/etc/nagios/

# cp cgi.cfg-sample cgi.cfg

# cp nagios.cfg-sample nagios.cfg

# cp resource.cfg-sample resource.cfg

Navigate to the /usr/local/etc/nagios/objects/ and do the  same :

# cd /usr/local/etc/nagios/objects/

# cp commands.cfg-sample commands.cfg

# cp contacts.cfg-sample contacts.cfg

# cp localhost.cfg-sample localhost.cfg

# cp printer.cfg-sample printer.cfg

# cp switch.cfg-sample switch.cfg

# cp templates.cfg-sample templates.cfg

# cp timeperiods.cfg-sample timeperiods.cfg

Now check you nagios configurations errors using following command

 

#  nagios -v  /usr/local/etc/nagios/nagios.cfg

You can create a password for the nagios web interface using the following command:

# htpasswd -c /usr/local/etc/nagios/htpasswd.users nagiosadmin

16-Now add Nagios to your apache configuration:

# ee /usr/local/etc/apache22/httpd.conf 

And at the end of the file add:

##########NAGIOS###########

ScriptAlias /nagios/cgi-bin/ /usr/local/www/nagios/cgi-bin/

Alias /nagios /usr/local/www/nagios/

<Directory /usr/local/www/nagios>

Options ExecCGI

AllowOverride None

Order allow,deny

Allow from all

AuthName “Nagios Access”

AuthType Basic

AuthUSerFile /usr/local/etc/nagios/htpasswd.users

Require valid-user

</Directory>

<Directory /usr/local/www/nagios/cgi-bin>

Options ExecCGI

AllowOverride None

Order allow,deny

Allow from all

AuthName “Nagios Access”

AuthType Basic

AuthUSerFile /usr/local/etc/nagios/htpasswd.users

Require valid-user

</Directory>

##########NAGIOS#############

Save the configuration and exit

17-Restart apache to check if any errors

# /usr/local/etc/rc.d/apache22 restart

Now  open your  nagios  page  with  Http://ip/nagios and  insert  your  login and  password created  before

Advertisements