Cacti Install and Config Guide

by | Nov 30, 2015 | Cacti

This is a easy-to-follow setup and config guide for of Cacti (Source install) on CentOS and Red Hat flavour OS. The setup is straightforward as it does not evolve any source code compiling but instead just a MySQL db setup and configuring users and permissions. The setup requires a user to have Root access to a Linux host.

Pre-requisites (minimal):

Hardware & Software

          CPU: 1 vCPU

                RAM: 2GB

                Hard Disk : 30GB

                OS: CentOS, Red Hat Enterprise Linux v 6.x.x

                Architecture : x64

Packages: httpd (apache), mysql,php,snmp,net-snmp and rrdtool

Cacti (Source):


Note: Make sure the Linux host is patched before install and config of Cacti

# yum update

Download Packages for Cacti Installation

Login to host shell and run these commands using YUM.

# yum -y install httpd httpd-devel mysql mysql-server php-mysql php-pear php-common php-gd php-devel php php-mbstring php-cli php-snmp net-snmp-utils net-snmp-libs rrdtool

And then download Cacti source from the link above.

# cd /tmp
# wget
# tar zxvf cacti-0.8.8f.tar.gz

After extracting the Cacti source file, rename and move it to /var/www/html

# mv cacti-0.8.8f cacti
# mv /tmp/cacti /var/www/html/ 

Once the above packages are installed, mysql ,httpd and snmpd need to be started and make them persistent across reboots.

# service mysqld start
# service httpd start
# service snmpd start
# chkconfig mysqld on
# chkconfig httpd on
# chkconfig snmpd on

Configure MySQL Server for Cacti Installation

First start with creating a password for MySQL server, use this command.

(Note: This is only for New Install of MySQL Install)

# mysqladmin -u root password YOUR-PASSWORD-HERE

Create MySQL Cacti DB

# mysql -u root -p
mysql> create database cacti;
mysql> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'db-password-here’;
mysql> FLUSH privileges;
mysql> quit;

Find the cacti.sql file to install cacti tables into newly created Cacti Database, using the following command.

# find / -name cacti.sql (in this case it’s in /var/www/html/cacti/cacti.sql)

Once you find the “.sql” file insert it in Cacti DB

# mysql -u cacti -p cacti < /var/www/html/cacti/cacti.sql

Configure MySQL settings for Cacti

# vi /var/www/html/cacti/include/config.php

/* make sure these values reflect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "db-password-here"; 
$database_port = "3306";
$database_ssl = false;

Configure Apache for securing Cacti WEBUI Access (optional)

First start with creating a new file in “/etc/httpd/conf.d/cacti.conf” to allow access to the WEBUI from the local network.

Create and edit cacti.conf”

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

<Directory /var/www/html/cacti/>
       Order Deny,Allow
       Deny from all
       Allow from 

Restart Apache

# service httpd restart 

Configure user and permissions for Cacti

Add user for cacti and make it a member of Apache

# useradd cacti 
# usermod -a -G cacti apache 

Change owner and permission of directories in Cacti folder

# cd /var/www/html/ 
# chown -R apache:cacti cacti 
# chmod ugo+r -R cacti 
# cd cacti 
# chmod 775 rra 
# chmod 775 log 

Note: Only If using SElinux run these commands

Put SElinux in permissive mode before making any changes

# setenforce 0 
# cd /var/www/html 
# chcon -R -h -t httpd_sys_content_t cacti 

Revert back to Enforcing mode for SElinux

# setenforce 1 

Add a CronJob for Cacti Polling

# vi /etc/cron.d/cacti

*/5 * * * *   cacti   /usr/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1 

Restart Cron Service

# service crond restart 

Finally, Cacti is now ready to be accessed via WEBUI https://IP-Address/cacti for initial setup. Default Username and Password — admin & admin

Related Articles….