LinuxSecurityVPS

How to Install Cacti on Cent OS

Hello all !!

Today we are going to see about how to install CACTI on cent OS. Cacti is open source monitoring tool for linux based systems. It provides graphical output about server’s resources like CPU, MEMORY, BANDWIDTH etc.

Requirements :

  1. Apache
  2. MySQL
  3. PHP
  4. PHP-SNMP
  5. NET-SNMP
  6. RRDTool

Now lets see how to install requiring packages for Cacti.

Installing Apache :

A Web server to display network graphs created by PHP and RRDTool.

Once you installed apache, Need to start the service.

[root@vps ~]# systemctl start httpd

 

Installing MySQL :

A Database server to store cacti information. You can install it through the below command.

[root@vps ~]# yum install maria mariadb-server

 

Installing PHP :

A script module to create graphs using RRDTool. Type the following command to install necessary php packages.

[root@vps ~]# yum install php-mysql php-pear php-common php-gd php-devel php php-mbstring php-cli

php-mysql, php-pear, php-common, php-gd, php-devel, php, php-mbstring, php-cli are essential for genraing graphical output through RRDTool.

 

Installing PHP-SNMP :

PHP extension for SNMP to access data. Use the below command to install SNMP extension.

[root@vps ~]# yum install php-snmp

 

Installing NET-SNMP :

A SNMP (Simple Network Management Protocol) is used to manage network. Type the below command to install it.

[root@vps ~]# yum install net-snmp-libs net-snmp-utils

 

Installing RRDTool :

A database tool to manage and retrieve time series data like CPU loadNetwork Bandwidth etc. Execute the below command to install it.

[root@vps ~]# yum install rrdtool

 

Lets install Cacti :

Before we installing Cacti, We need enable EPEL repository.

What is EPEL :

EPEL (Extra Packages for Enterprise Linux) is open source and free community based repository project from Fedora team which provides 100% high quality add-on software packages for Linux distribution including RHEL, CentOS and for major Linux distributions. It  providing lots of open source packages like networking, sys admin, programming, monitoring and so on. Most of the epel packages are maintained by Fedora repo.

First we have to download and install the repository. You can download it using wget uttlity.

[root@vps ~]# wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

Once downloaded we can install it using RPM. Use the below command to install the epel repository.

[root@vps ~]# rpm -ivh epel-release-latest-7.noarch.rpm

Once you installed, you can verify it through

[root@vps ~]# yum repolist

Once you enable EPEL repom, you can install cacti using below command

[root@vps ~]# yum install cacti

 

Configuring MySQL server for Cacti :

Now we have create a database and database user for cacti. Here I’m going to create both Db and user as cacti.

Login to your Mysql server as

[root@vps ~]# mysql -u root -p

Then you are asked for password for mysql root user. Once you entered the password you will get into MySQL prompt.

Then execute below queries to create Database.

>create database cacti;
>GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'yourpassword';
>FLUSH privileges;

Then we have to find out cacti database file using RPM

[root@vps ~]# rpm -ql cacti | grep cacti.sql

It’s output will be like in the below screen shot.

Then to install tabled into cacti database, Please execute the below command.

Then open the file /etc/cacti/db.php and make changes mentioned on below

$database_type = ‘mysql’;
$database_default = ‘cacti’;
$database_hostname = ‘localhost’;
$database_username = ‘cacti’;
$database_password = ‘Your passsword’;
$database_port = ‘3306’;
$database_ssl = false;

Configuring Firewall for Cacti :

Execute the below command.

[root@vps ~]# firewall-cmd –permanent –zone=public –add-service=http

[root@vps ~]# firewall-cmd –reload

Configuring Apache Server for Cacti Installation :

Open the file /etc/httpd/conf.d/cacti.conf and do the modification mentioned on below and save it.

Alias /cacti /usr/share/cacti

<Directory /usr/share/cacti/>
<IfModule mod_authz_core.c>
# httpd 2.4
Require all granted
</IfModule>
<IfModule !mod_authz_core.c>
# httpd 2.2
Order deny,allow
Deny from all
Allow from all
</IfModule>

 

Setting Cron for Cacti :

Open file /etc/cron.d/cacti.

# vi /etc/cron.d/cacti

Set the poller.php script runs every 5 mins.

#*/5 * * * *    cacti   /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1

Cacti Installer :

Now try to access the the URL http://YourIPaddress/cacti and you will installer page.

Check License Agreement and click Begin to start the installation. Next you will be shown of pre-installation checks page. Here If all the requirements matches with the installed version, then you can install it.

Congratulations, Now you have successfully installed Cacti monitoring tool in your server.

 

Leave a Reply

Your email address will not be published. Required fields are marked *