Exercise 1 - Nagios Installation and Configuration on FreeBSD-9.1 ================================================================== 1. Install MySQL Server 5.5 from ports. ---------------------------------------------------------------------------------- # cd /usr/ports/databases/mysql55-server # make all install clean 1.1 Enable and launch the mysql service by editing /etc/rc.conf and add the below line. mysql_enable="YES" or issue the following command: # echo 'mysql_enable="YES"' >> /etc/rc.conf 1.2 Start the mysql server using command below # /usr/local/etc/rc.d/mysql-server start 1.3 Set the mysql admin password to "afnog" # mysqladmin -u root password "afnog" 1.4. Log in to mysql console to check if the password was set properly using command below. # mysql -u root -p Password: Type the password at the prompt. You can exit from the mysql> prompt by typing "exit" command 2. Install Apache from ports. ---------------------------------------------------------------------------------- # cd /usr/ports/www/apache22 # make all install clean 2.1 Enable mysql-support in the blue screen that comes up 2.2 Enable and launch the apache service by adding the below line to /etc/rc.conf apache22_enable="YES" or issue the following command: # echo 'apache22_enable="YES"' >> /etc/rc.conf 2.3 Start Apache service: # /usr/local/etc/rc.d/apache22 start 2.4 Test the apache page http:// or http:// 3. Install PHP5 and php5-extension: ------------------------------------------------------------------------------------ # cd /usr/ports/lang/php5 # make all install clean Make sure to enable [*] APACHE module in the install Step (Blue screen) # cd /usr/ports/lang/php5-extensions # make all install clean Select [*] SESSIONS and [*] MYSQL support in the configurations options (Blue screen) 3.1 PHP Configuration Settings for PHP are stored in the /usr/local/etc/php.ini file. 3.2 Copy the distribution file by issuing the following command # cp /usr/local/etc/php.ini-development /usr/local/etc/php.ini 3.3 Edit /usr/local/etc/php.ini and uncomment the following: ; display_errors Default Value: On Development Value: On ; Production Value: Off ; display_startup_errors Default Value: Off Development Value: On ; Production Value: Off ; error_reporting Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED Development Value: E_ALL ; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT ; html_errors Default Value: On Development Value: On ; Production value: On ; log_errors Default Value: Off Development Value: On ; Production Value: On Save and exit php.ini 3.4 Also Apache needs to be configured, so it can use php. # cd /usr/local/etc/apache22/ # vi 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 the apache configuration file. 3.5 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. 3.6 To test PHP, create the following file in the apache # echo "" >> /usr/local/www/apache22/data/test.php Now check the phpinfo page http:///test.php 4. Install Nagios: ----------------------------------------------------------------------------------------- # cd /usr/ports/net-mgmt/nagios # make all install clean 4.1 Use the default installation, however, in installation screen of nagios plugins don't forget to add NETSNMP to Nagios group and user. 4.2 Enable nagios to start at boot time by add the line below to /etc/rc.conf nagios_enable="YES" or enter the following command to append the entry in the /etc/rc.conf file. # echo 'nagios_enable="YES"' >> /etc/rc.conf 4.3 Now copy the sample configuration files and rename them by issuing the following commands: # 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 4.4 You can create a password for the nagios web interface using the following command: # htpasswd -c /usr/local/etc/nagios/htpasswd.users nagiosadmin New password: ****** Re-type new password: ****** 4.5 Now add Nagios to your apache configuration: # vi /usr/local/etc/apache22/Includes/nagios.conf And add the following text to the file: ##########NAGIOS Config for Apache22########### ScriptAlias /nagios/cgi-bin/ /usr/local/www/nagios/cgi-bin/ Alias /nagios /usr/local/www/nagios/ Order deny,allow Deny from all Allow from all AuthName "Nagios Access" AuthType Basic AuthUSerFile /usr/local/etc/nagios/htpasswd.users Require valid-user php_flag engine on php_admin_value open_basedir /usr/local/www/nagios/:/var/spool/nagios/ Options ExecCGI ##########NAGIOS Config for Apache22############# Save the configuration and exit 4.6 Restart apache and check for any errors # /usr/local/etc/rc.d/apache22 restart 4.7 Start nagios by issuing the following command: # /usr/local/etc/rc.d/nagios start 4.8 Now open your nagios page with http:///nagios and insert your login and password created before.