How to install and configure Cacti on CentOS 7

Cacti stores all of the necessary data to create graphs and populate them with data in a MySQL database.

Cacti is an open source network and system monitoring graphing tool. It is used to get a graph for network bandwidth utilization, CPU /Load, RAM, and as such. In addition to that, it monitors the network traffic by polling a router or switch via SNMP.

This tutorial is about how to install Cacti and configure it so that you have it up and running.

Install and configure Cacti on CentOS

Here we use root login for this installation and configuration. Before doing anything else, we should disable SELinux.

Step 1 –  Disable SELinux

Open and edit SELinux configuration file.

vim /etc/sysconfig/selinux

Change  SELINUX=enforcing to SELINUX=disabled. Save and exit. Reboot system


Step 2 – Enable Repos

Head over to the Fedora page and copy the latest download link of the latest file.

Setup the EPEL repository:

rpm -Uvh

Similarly, copy the link of Remi and install the Remi repository.


Install repository.

rpm -Uvh remi-release-7.rpm

List repositories.

yum repolist

Step 3 – Install Apache

Let’s install Apache and start the service.

yum install httpd httpd-devel
systemctl start httpd

Step 4 – Install SNMP and RRDTool

To install SNMP and RRD Tool, enter the following command:

yum  install net-snmp net-snmp-utils net-snmp-libs rrdtool

Accept typing “Y” to confirm installation.

Start SNMP.

systemctl start snmpd

Step 5 – Install MariaDB Server

Use the following command to install the MariaDB server and start the service.

yum install mariadb-server
systemctl start mariadb

Complete MariaDB Secure Installation.


Secure Installation
Secure Installation

Step 6 – Install PHP and needed packages

Fire up the following command to install a bunch of PHP related packages.

yum --enablerepo=remi install php-mysql php-pear php-common php-gd php-devel php php-mbstring php-cli php-intl php-snmp

Step 7 – Create a Cacti Database

Now you can log in to the database server with the previously configured password.

mysql -u root -p

Login to MariaDB
Login to MariaDB

Create a Database and user.

MariaDB [(none)]> create database fosslinuxcacti;
MariaDB [(none)]> CREATE USER 'fosslinuxuser'@'localhost' IDENTIFIED BY 'C345gDvfr@#231';

Grant permission and flush privileges.

 MariaDB [(none)]> grant all privileges on fosslinuxcacti.* to fosslinuxuser@localhost ;

Create DB and User
Create DB and User

Create database user should have access to the mysql.time_zone_name Table. So we should import the mysql_test_data_timezone.sql to MySQL database first.

mysql -u root -p mysql < /usr/share/mysql/mysql_test_data_timezone.sql

Login to MariaDB.

mysql -u root -p

Grant access to the cacti database user and flush privileges.

MariaDB [(none)]> GRANT SELECT ON mysql.time_zone_name TO fosslinuxuser@localhost;
MariaDB [(none)]> flush privileges;

Time Zone
Time Zone

Step 8 – Optimize Database

We need to modify database parameters for better performance. Use the following command.

vim /etc/my.cnf.d/server.cnf

Add the following lines to the [mysqld] section.

collation-server = utf8_general_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
max_heap_table_size = 128M
max_allowed_packet = 16777216
tmp_table_size = 64M
join_buffer_size = 64M
innodb_file_per_table = on
innodb_buffer_pool_size = 512M
innodb_doublewrite = off
innodb_additional_mem_pool_size = 80M
innodb_lock_wait_timeout = 50
innodb_flush_log_at_trx_commit = 2

Database Parameters
Database Parameters

When done, restart the MariaDB service using the restart command:

systemctl restart mariadb.service

Step 9 – Install and configure Cacti

Time to install Cacti now using YUM.

yum -y install cacti

Import default cacti database file to the created database.

cd /usr/share/doc/cacti-1.1.38

Import the SQL file.

mysql -u root -p  fosslinuxcacti < cacti.sql

Edit the Cacti configuration file which includes a database, password details etc.

vim /usr/share/cacti/include/config.php

Modify database details.

$database_type     = 'mysql';
$database_default  = 'fosslinuxcacti';
$database_hostname = 'localhost';
$database_username = 'fosslinuxuser';
$database_password = 'C345gDvfr@#231';
$database_port     = '3306';
$database_ssl      = false;

Cacti Configuration File
Cacti Configuration File

Step 10 – Set Cron for Cacti

Open cacti cron file.

vim /etc/cron.d/cacti

Uncomment the following line.

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

Cron For Cacti
Cron For Cacti

Save and exit the file.

Step 11 – Configure Apache for Cacti

This will help us to do a remote installation. Edit the cacti config file.

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

Change  “Require host localhost” to “Require all granted” and “Allow from localhost” to “Allow from all.”

Cacti Apache Configuration
Cacti Apache Configuration

Change Time Zone.

vim /etc/php.ini
date.timezone = your time Zone

E.g.:- date.timezone = Australia/Sydney

Restart apache, MariaDB, and SNMP.

systemctl restart httpd.service
systemctl restart mariadb.service
systemctl restart snmpd.service

Step 12 – Configure the Firewall

Use these commands:

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --reload

Step 13 – Start Cacti installation

Open a web browser and use the following URL to access Cacti web interface.


You will see the Licence Agreement page Then accept it and click Begin.

License Agreement
License Agreement

You should see Pre-installation checks. Click next if there are no issues.

Pre-installation Checks
Pre-installation Checks

Next window is Installation Type. It will show Database connection details. Click Next to continue.

Installation Type
Installation Type

Verify Critical Binary Locations and Versions and then click next.

Critical Binary Locations and Versions
Critical Binary Locations and Versions

Verify Directory Permissions and continue.

Directory Permission Checks
Directory Permission Checks

In the Template Setup window, you can select all templates, and click finish to the complete installation.

Template Setup
Template Setup

After the installation, it will redirect to Login Page.

Login Page
Login Page

Using default user name “admin” and default password “admin” you can log in to Cacti server. You should be asked to change the password after that.

Change Password

Change PasswordChange password and click save. Then you should see the Cacti Dashboard.

Cacti Dashboard
Cacti Dashboard

You can add new devices from Managemnt-> Devices Then click plus mark “+” on top of the right-hand corner.

Add Devices
Add Devices



That’s it! You have successfully configured Cacti on CentOS 7!

Hey! I'm Darshana, a Linux / DevOps Engineer and also a contributor to FOSS Linux. I enjoy working on various kind of Linux distributions and cloud technologies. During my free time, I love to swim and hike across nature trails. Linux is my love and I'm here to share all my learnings with all of you! Hope you enjoyed reading my article.





Buyers who wish to go for a machine that is based on Linux often show interest in Chromebooks due to the form factor and extended battery life capabilities. Although ChromeOS power these machines, users can still miss out on a more genuine Linux experience. For those who happen to agree, the new Lemur Pro by System76 might get some heads turning.
Linux is growing faster than ever. As per the latest report, there is a drop in the Windows 10 market share for the first time, and Linux's market share has improved to 2.87% this month. Most of the features in the list were rolled out in the Pop OS 20.04. Let's a detailed look into the new features, how to upgrade, and a ride through video.

5 ways to send emails using the command-line in Linux

Did you master using the command-line in Linux? There is no limit to what one can do via the Linux Terminal. One of such things we are going to discuss today are methods of sending an email using the command-line.

CentOS vs. Fedora: Key Differences

Both Fedora and CentOS are RPM-based Linux distributions. The two share a lot of features in common but still have several differences. In this post, we introduce both Fedora and CentOS and look at their key differences in this comparison article.

15 Tar command in Linux uses with examples

Tar is a famous utility that is basically used for collecting multiple files in a single archive. This file is often called a 'tarball'. Today, we are going to tell you about the different things you can do with tarballs using the tar command, with practical examples.

Top 10 reasons to use KDE as your Desktop Environment

In this article, we will take a look at yet another popular desktop environment, KDE. It's one of the most amazing Linux Desktop environments available in the market.