How to install Cacti network monitoring tool on a Centos VPS

cactiCacti is an open source web based network and system monitoring solution with a completely PHP driven frontend. It is used by IT businesses and stores all of the necessary information about bandwidth, hard disk usage, CPU usage, load average, RAM statistics etc in a MySQL database. Cacti creates graphs and populates them with data. It offers SNMP support, 3rd party templates and plugins and has built in user authentications and user permission features.

This blog article will guide you through the installation of Cacti on a Centos VPS.


Login to your Centos 6 virtual private server as user ‘root’ and install the required packages:

Install Apache

# yum install httpd httpd-devel

Install MySQL

# yum install mysql mysql-server

Install PHP and the necessary modules

# yum install php-mysql php-pear php-common php-gd php-devel php php-mbstring php-cli php-mysql

Install PHP-SNMP

# yum install php-snmp

Install NET-SNMP

# yum install net-snmp-utils p net-snmp-libs

Install RRDTool

# yum install rrdtool

Next we need to start the required services:

# /etc/init.d/mysqld start
# /etc/init.d/httpd start
# /etc/init.d/snmpd start

In order for these services to run at startup we need to enter the following commands:

# chkconfig mysqld on
# chkconfig httpd on
# chkconfig snmpd on

We must download the EPEL repository in order to install Cacti via the yum package manager.

# wget
# rpm -ivh epel-release-6-8.noarch.rpm
# yum install cacti


Now we need to run the post-installation script ‘mysql_secure_installation’ in order to set a root password.

# mysql_secure_installation
 - Set root password? [Y/n] y
 - Remove anonymous users? [Y/n] y
 - Disallow root login remotely? [Y/n] y
 - Remove test database and access to it? [Y/n] y
 - Reload privilege tables now? [Y/n] y


Cacti requires a MySQL user and database, so create them by executing the following commands:

# mysql -u root -p
create database cacti;
grant all privileges on cacti.* to 'cactiuser'@'localhost' identified by 'your-password-here';
flush privileges;


Setup Cacti Tables in MySQL
We need to know the location of the cacti.sql file. Use the following command to show the location:

# rpm -ql cacti | grep cacti.sql

Sample output: /usr/share/doc/cacti-0.8.8b/cacti.sql

Now we need to install the tables into the cacti.sql file. Use the following command to do this and enter your database password when prompted.

# mysql -u cactiuser -p cacti < /usr/share/doc/cacti-0.8.8b/cacti.sql

Let’s configure MySQL settings for Cacti. Open /etc/cacti/db.php with your favourite editor and enter the values for your ‘cacti’ database.

# vim /etc/cacti/db.php








Configure the Apache Server for Cacti Installation.

You need to allow access to Cacti from the IP address ranges you require. Open /etc/httpd/conf.d/cacti.conf with your preferred text editor:

# vim /etc/httpd/conf.d/cacti.conf

Add the following section at the bottom of the config file:

<Directory /usr/share/cacti/>
 Order Deny,Allow
 Deny from none

Restart Apache:

# /etc/init.d/httpd restart

Setting Cron for Cacti
Open the Cacti cron file and and uncomment the line to enable poller.php to run every 5 minutes.

# vim /etc/cron.d/cacti

Remove the # in the following line

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

The installation is complete. You can now open your favorite web browser and navigate to http://SERVER-IP/cacti to finish the installation. The default username and password for Cacti is admin / admin. Upon first login, you will be force to change the default password.

Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to install Cacti for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Leave a Comment

To prove you are human please solve the following *