Posts

How to Configure Nagios monitoring server

Nagios is the most popular, open source, powerful monitoring system. It enables organizations to identify and resolve IT infrastructure problems before they affect critical business processes. With Nagios, you can monitor your remote hosts and their services remotely on a single window. It shows warnings and indicates if something goes wrong in your servers which eventually helps us to detect some problems before they occur. It helps us to reduce downtime and business losses. Nagios has capability of monitoring application, services, entire IT infrastructure.

Step 1: Prerequisites

Firstly install all the required libraries that are dependent on nagios installation:

# yum install -y httpd php gcc glibc glibc-common gd gd-devel make net-snmp

Start Services:

# service httpd start

Step 2: Create User Accounts & group

Now create a new nagios user account and setup a password to this account

# useradd nagios
# passwd nagios

Now create a groud for nagios setup “nagcmd” and add nagios user to this group. Also add nagios user in apache group.

# groupadd nagcmd
# usermod -a -G nagcmd nagios
# usermod -a -G nagcmd apache

Step 3: Install Nagios Core Service

After installing required dependencies and adding user accounts. Lets start with Nagios core installation. Download latest nagios core service from official site.

# cd /opt/
# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.8.tar.gz
# tar xzf nagios-4.0.8.tar.gz
# cd nagios-4.0.8
# ./configure --with-command-group=nagcmd
# make all
# make install
# make install-init
# make install-config
# make install-commandmode

Now use below command to setup apache configuration for Nagios installation.

# make install-webconf

Step 4: Configure Apache Authentication

We need to setup apache authentication for user nagiosadmin. Do not change this username. else you would required more changes in configuration.

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

Now restart Apache service to make the new settings take effect.

# service httpd restart

Step 5: Install Nagios Plugins

After installing and configuring Nagios core service, Download latest nagios-plugins source and install using following commands.

# cd /opt
# wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
# tar xzf nagios-plugins-2.0.3.tar.gz
# cd nagios-plugins-2.0.3

Now compile and install nagios plugins

# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
# make
# make install

Step 6: Verify and Start Nagios

Use the following commands to verify nagios install and start nagios core service.

# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
# service nagios start

Also configure nagios service to start on system start

# chkconfig --add nagios
# chkconfig nagios on

Step 7: Install Centreon

Use the following commands to install Centreon.

# cd /usr/local/src
# wget http://download.centreon.com/centreon/centreon-2.3.8.tar.gz
# tar -zxf centreon-2.3.8.tar.gz
# cd centreon-2.3.8
# ./install.sh -i

Step 8: Test in Web Browser

Nagios creates its own apache configuration file /etc/httpd/conf.d/nagios.conf. There are no need to make any changes to it. Simply open below url in browser.
[change domain name with your domain or ip]

 http://Your-IP-Address/nagios/

How to Install SubVersion in Linux

Subversion is a free/open-source version control system.

Step 1: Prerequisites

Step 2: Install Subversion

Use following command to install subversion and mod_dav_svn packages.

# yum install mod_dav_svn subversion

Step 3: Configure Subversion with Apache

Create a file and edit the file with following changes:

# touch /etc/httpd/conf.d/subversion.conf
# vim /etc/httpd/conf.d/subversion.conf

LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so
<Location /svn>
   DAV svn
   SVNParentPath /var/www/svn
   AuthType Basic
   AuthName "Subversion User Authentication "
   AuthUserFile /etc/svn-auth-users
   Require valid-user
</Location>

Step 4: Create SVN User

# htpasswd -cm /etc/svn-users test_user

Step 5: Create SVN Repository

Use following command to create your fist svn repository.

# cd /var/www/svn
# svnadmin create testrepo
# chown -R apache.apache testrepo
# chcon -R -t httpd_sys_content_t /var/www/svn/testrepo/
# chcon -R -t httpd_sys_rw_content_t /var/www/svn/testrepo/

Step 6: Open Page on Browser

Test the SVN repository on your favorite browser

http://Your-IP/svn/testrepo/

Step 7: Configure svnserve.conf file

Edit the svnserve.conf file and make the following changes:

# vi /var/www/svn/testrepo/conf/svnserve.conf
anon-access = none authz-db = authz

Step 8: Create sample directories

Create sample subversion directories

# mkdir subversion_templates
# cd subversion-templates/
# mkdir packages
# mkdir patches
# mkdir downloads

Step 9: Import the Subversion repository

Import the Subversion repository.

# svn import -m 'Initial import' subversion-templates/ http://Your-IP-Address/svn/repo/
Adding         subversion-templates/packages
Adding         subversion-templates/patches
Adding         subversion-templates/downloads
Committed revision 2.

How to Install PHP in Linux

Step 1: Prerequisite

Step 2: Install PHP

Run the yum install command

# yum install php-mysql php-devel php-gd php-pecl-memcache php-pspell php-snmp php-xmlrpc php-xml

Step 3: How to configure PHP

# vi /etc/php.ini
memory_limit = 128M
max_execution_time = 120
max_upload_size = 50M
post_max_size = 50M

Step 4: Create PHP page

Create the /var/www/html/phpinfo.php file with the following text:

# touch /var/www/html/phpinfo.php
# vi /var/www/html/phpinfo.php
<?php
phpinfo();
?>

Step 5: Restart Apache Server

Now restart Apache Server

# service httpd restart

Step 6: Open Page on Browser

Test the php page on your favorite browser:
http://Your-IP-address/phpinfo.php

How to Configure Multiple Domains in Web Server

Step 1: Prerequisite

Step 2: Add Domains in Apache Configuration File

To add multiple domains in web server edit /etc/http/conf/httpd.conf file and create virtual hosts.

# vi /etc/http/conf/httpd.conf
NameVirtualHost 10.0.0.10
<VirtualHost *:80>
    ServerAdmin webmaster@tecdistro.com
    DocumentRoot /var/www/html/tecdistro.com
    ServerName www.tecdistro.com
    ServerAlias tecdistro.com
    ErrorLog /var/log/tecdistro.com-error_log
    CustomLog /var/log/tecdistro.com-access_log common
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin webmaster@tecdistro.org
    DocumentRoot /var/www/html/tecdistro.org
    ServerName www.tecdistro.org
    ServerAlias tecdistro.org
    ErrorLog /var/log/tecdistro.org-error_log
    CustomLog /var/log/tecdistro.org-access_log common
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin webmaster@tecdistro.net
    DocumentRoot /var/www/html/tecdistro.net
    ServerName www.tecdistro.net
    ServerAlias tecdistro.net
    ErrorLog /var/log/tecdistro.net-error_log
    CustomLog /var/log/tecdistro.net-access_log common
</VirtualHost>

Step 3: Restart Apache Server

After the changes have made, Restart the apache server:

# service httpd restart
OR
# /etc/rc.d/init.d/httpd restart

How to Configure Website Using Htaccess with Apache in Linux

Step 1: Prerequisite

Step 2: Create Directory

Create a directory in /var/www/html/ (where DocumentRoot of apache is pointed).

# mkdir /var/www/html/testfolder
# cd /var/www/html/testfolder

Step 3: Create .htaccess File

Now create a .htaccess file using the touch command and insert the following lines in it:

# touch .htaccess
# vi .htaccess
AuthUserFile /var/www/html/testfolder/.htpasswd
AuthGroupFile /www.null
AuthName "Authorization Required"
AuthType Basic

require user USER_NAME

Set the password by executing the htpasswd command for htaccess

# htpasswd -c /var/www/html/testfolder/.htpasswd USER_NAME

Step 4: Configuration in Apache

Edit the /etc/httpd/conf/httpd.conf file and add the lines:

# vi /etc/httpd/conf/httpd.conf
<Directory "/var/www/html/testfolder">
AllowOverride AuthConfig
</Directory>

Step 5: Restart Apache Server

In the end restart the httpd service:

# service httpd restart

How To Install Apache (Web Server) in Linux

For Fedora / RHEL / Cent OS Linux

Step 1: Install apache

# yum install httpd

Step 2: Start apache

To start the Apache/httpd, run:

# /etc/init.d/httpd start
OR
# service httpd start

Also configure httpd service to start on system start.

# chkconfig httpd on

Note: The default directory in Fedora / RHEL / Cent OS Linux operating system is “/var/www/html”

Step 3: Verify apache Port

To verify the httpd port is open or not use the command:

# netstat -antp | grep :80

For Debian / Ubuntu

Step 1: Install apache

Use the apt-get command:

# apt-get install apache2

Step 2: Start apache

# /etc/init.d/apache2 start

Note: The default directory in Debian / Ubuntu Linux operating system is /var/www/

Installation from CD/DVD

We can also install httpd from CDROM with rpm command:

# rpm -ivh httpd*