How to Install Cacti on CentOS 6 / RHEL 6
Cacti is an open source web-based network monitoring tool designed as the front end application for the RRDtool (Round-Robin database tool), it allows a user to poll the services at an interval of time and resulting in the graph format.
Cacti is generally used to get a graph data for the CPU and network bandwidth utilization, it monitors the network traffic by polling a router or switch via SNMP.
Here is the small tutorial on how to install Cacti on CentOS 6 / RHEL 6.
Requirements
Setup EPEL repository on your system.
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
Install the following packages for the Cacti setup.
yum -y install httpd php php-mysql php-snmp mysql mysql-server net-snmp rrdtool net-snmp-utils
Install the following PHP extension.
yum -y install php-xml php-session php-sockets php-ldap php-gd
Make the services are started at startup.
chkconfig httpd on chkconfig mysqld on chkconfig snmpd on
Start the following services.
service httpd start service snmpd start service mysqld start
Database
Create a database for Cacti. If you are configuring the MySQL for the first time, then take a look at how to secure the MySQL.
# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
Create Cacti database.
create database cacti;
Grant permission to the newly created database.
GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cactipassword'; flush privileges; exit
The database user (cactiuser) should have access to the mysql.time_zone_name Table. To do that, import the mysql_test_data_timezone.sql to mysql database first.
mysql -u root -p mysql < /usr/share/mysql/mysql_test_data_timezone.sql
Then, log in to MySQL server.
mysql -u root -p
Grant the permission to cactiuser.
GRANT SELECT ON mysql.time_zone_name TO cactiuser@localhost; flush privileges; exit
Install and Configure Cacti
Install the latest version of Cacti using YUM command.
yum -y install cacti
Configure Cacti
Import the default database to the cacti database.
mysql cacti < /usr/share/doc/cacti-*/cacti.sql -u root -p
Edit the config file to specify the database type, name, hostname, user, and password information.
vi /usr/share/cacti/include/config.php
Make the changes accordingly.
/* make sure these values reflect your actual database/host/user/password */ $database_type = "mysql"; $database_default = "cacti"; $database_hostname = "localhost"; $database_username = "cactiuser"; $database_password = "cactipassword"; $database_port = "3306"; $database_ssl = false;
Add the following entry in the crontab (/etc/crontab) to poll every five min.
*/5 * * * * cacti php /usr/share/cacti/poller.php > /dev/null 2>&1
Edit apache configuration file to perform the remote installation.
vi /etc/httpd/conf.d/cacti.conf
Modify the first directory stanza, from “Allow from localhost”
<Directory /usr/share/cacti/>
<IfModule mod_authz_core.c>
# httpd 2.4
Require host localhost
</IfModule>
<IfModule !mod_authz_core.c>
# httpd 2.2
Order deny,allow
Deny from all
Allow from localhost
</IfModule>
</Directory>
To “Allow from 192.168.12.0/24” – Your network.
<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 192.168.12.0/24
</IfModule>
</Directory>
Set the timezone by editing /etc/php.ini file.
vi /etc/php.ini
Update the timezone.
date.timezone = US/Eastern
Restart the services.
service httpd restart service snmpd restart service mysqld restart
SELinux
Consider disabling SELinux on your system for Cacti to work properly. For a temporary solution, run the following command to disable SELinux until you reboot the system.
setenforce 0
Firewall
Run the following command on the terminal to allow access to Cacti web interface through the firewall.
iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT service iptables save
Setup Cacti Web Interface
Visit the following URL to start the installation of cacti. https://your-ip-address/cacti. Click on Next to continue.

In this page, look for any errors the Cacti reports to you about your machine. Go down and click Next.


You could see some recommendation from Cacti for MySQL variables. It is up to you to follow that.
Scroll down for the options. Select New Primary Server for the new installation and then click Next.

It will show you if there is any package is missing which is mandatory for the cacti.

You can ignore the Spine error as we will be using built-in Cacti poller.
Make sure directories are writable.

Install Cacti templates.

Enter User Name and Password (Default admin/admin)

You must change the default password.

The following shows the dashboard of the cacti.

Now you can start configuring the Cacti to monitor your devices. More documentation can be found here.
We welcome your comments, please post your valuable comments below.