Call us Today +49 7543 609337-0
Log In

In this posting you will be learning how to install Cacti on RockyLinux 8 system. This guide should be valid for Centos 8 and RHEL 8 as well.

Addition Information

Website showing the result of an install Cacti on RockyLinux 8

Step 1 – Prerequisites

First we need to install some of the software packages needed for Cacti to run properly. Using a minimal installation, we need to install the following repositories and packages

  • epel and remi repository
  • rrdtool
  • Apache
  • mariadb
  • PHP and modules
  • gcc, net-snmp and dev packages for spine installation

In order to use python for scripting purposes ( or ansible), we are also going to install it as well.

Let’s proceed with the package installation on our RockyLinux 8 system. First we will enable the required EPEL ad REMI repositories:

dnf install -y epel-release
dnf install -y dnf-utils
sudo dnf -y module reset php
sudo dnf -y module enable php:remi-8.0
sudo dnf config-manager --set-enabled powertools

Now we can proceed with installing the packages:

dnf -y install mariadb-server php php-mysqlnd php-cli net-snmp-utils rrdtool gcc mariadb-devel
dnf -y install net-snmp-devel autoconf automake libtool dos2unix wget php-posix php-ldap php-mbstring php-gd
dnf -y install php-gmp php-zip php-json php-xml php-gettext php-curl php-intl help2man
dnf -y install net-snmp net-snmp-devel net-snmp-utils

Now let’s install git and python, and also make sure we have the setuptool-rust installed in case we want to run ansible. Lastly we also install some tools to manage SELinux:

dnf -y install git python3-pip python3-devel python3-dnf
dnf -y install policycoreutils-gui
sudo pip3 install setuptools-rust 
sudo pip3 install --upgrade pip

In order to have all packages up-to-date, let’s do a quick upgrade on our system as well:

dnf -y upgrade

The above completes the specifics for the install Cacti on RockyLinux 8. Most of the tasks below are valid for a CentOS7/RHEL7 instalaltion as well.

In the next step, we will make sure that our webserver and the database are automatically starting up after a reboot. In order to do this, use the following commands to enable these:

systemctl enable httpd.service
systemctl enable mariadb.service
systemctl restart mariadb.service

Now that we have the database server started, we need to populate it with the timezone data:

# Create the timezone data and import it into the mysqldatabase
mysql_tzinfo_to_sql /usr/share/zoneinfo > /tmp/mysql_timezone.sql
mysql mysql < /tmp/mysql_timezone.sql

Next, we need to change some settings for the mariadb server. These will make sure that spine and Cacti are utilizing the database connection in an optimal way. The following settings are for a 1GB memory system.

Don’t worry, Cacti will provide you with some recommended settings for your system during the installation process.

So, let’s edit the /etc/my.cnf.d/mariadb-server.cnf file and add the following lines to the [mysqld] section:


Make sure to adapt the default-time-zone to your requirements

Next, we need to restart the web-server as well as the Maria DB service in order to continue the installation:

systemctl restart httpd.service
systemctl restart mariadb.service

[the_ad_placement id=”default-manual”]

Step 2 – Cacti Files

Let’s now move to the actualy installation of Cacti. First we need to download and extract it. As of this writing the current Cacti Version is 1.2.22.

cd /var/www/html
tar -xzvf cacti-latest.tar.gz

Let’s now rename the cacti directory:

mv cacti-1.2.23 cacti

Step 3 – File permissions

We also need to make sure that the ownership of the required cacti directory is set correctly:

chown -R apache.apache /var/www/html/cacti/rra 
chown -R apache.apache /var/www/html/cacti/log
chown -R apache.apache /var/www/html/cacti/resource/snmp_queries/
chown -R apache.apache /var/www/html/cacti/resource/script_server/
chown -R apache.apache /var/www/html/cacti/resource/script_queries/
chown -R apache.apache /var/www/html/cacti/scripts/
chown -R apache.apache /var/www/html/cacti/cache
chown -R apache.apache /var/www/html/cacti/include/vendor/csrf
chmod -R 775 /var/www/html/cacti/cache
chmod -R 775 /var/www/html/cacti/resource
chmod -R 775 /var/www/html/cacti/scripts
chmod -R 775 /var/www/html/cacti/include/vendor/csrf

Step 4 – Cacti Database

Now that we have extracted the cacti files, we can move on preparing the database for the final installation step. Your first step should be securing the mysql database. The following command will help you with this task on a CentOS system. Make sure to select a strong password for root, e.g. MyN3wpassw0rd


Let’s create a new database and assign a special user to it:

mysqladmin -u root -p create cacti
mysql -p cacti < /var/www/html/cacti/cacti.sql
mysql -u root -p

With the last command, you should be seeing a mysql prompt where you can enter mysql commands. Here we are going to create the special cacti user. That user only needs to be able to connect from the local system and should have a strong password as well. Enter the following commands and make sure to replace the password:

GRANT SELECT ON mysql.time_zone_name TO cactiuser@localhost IDENTIFIED BY 'MyV3ryStr0ngPassword';
GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'MyV3ryStr0ngPassword';
flush privileges;

We now have the cacti files and the cacti database setup. The last step before moving to the web-based installer is setting the database credentials within the Cacti config file:

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

Change the $database_ lines to fit your new settings:

$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "MyV3ryStr0ngPassword";
$database_port = "3306";
$database_ssl = false;

Depending on your installation, you should also uncomment the following line. In our example we have to make sure the following line is there:

$url_path = "/cacti/";

Step 5 – Adding firewall rules

The following settings will enable the firewall and add access rules to http and https from outside:

systemctl enable firewalld
systemctl start firewalld
firewall-cmd --permanent --zone=public --add-service=https 
firewall-cmd --permanent --zone=public --add-service=http 
firewall-cmd --reload

Step 6 – Important PHP Settings

The default PHP installation usually has not configured the correct timezone or php error reporting. While not required to run Cacti, it’s highly recommended to enable error reporting to syslog for troubleshooting issues with plugins or other scripts.

The following lines need to be enabled/configued in your /etc/php.ini file:

; Defines the default timezone used by the date functions
date.timezone = Europe/Berlin


; Log errors to syslog (Event Log on NT, not valid in Windows 95).
error_log = syslog

and also increase the memory limit and max execution time:

memory_limit = 400M
max_execution_time = 60

Let’s restart the HTTP and PHP-FPM services

systemctl restart httpd.service
systemctl restart php-fpm

Step 7 – Set SELinux Context for http directory

SELinux does interfere with the installation, so let’s disable it for now. :

sudo chcon -R -t httpd_sys_rw_content_t /var/www/html
sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html(/.*)?"

Step 8 – Running the Web-based installer

Let’s move on to the web-based installer.


Login with admin/admin and you’re ready to go !

Please go to “Console -> System Utilities” and click on “Rebuild Poller Cache” after the first login!


Step 9 – Installing Spine

Now let us look into installing Spine as a replacement of the cmd.php poller.

The following task will download, compile and configure the spine poller:

## Install Spine
cd /tmp
tar -xzvf cacti-spine-latest.tar.gz
cd cacti-spine-1.2.23
sudo ./bootstrap
sudo ./configure
sudo make
sudo make install
sudo chown root:root /usr/local/spine/bin/spine
sudo chmod +s /usr/local/spine/bin/spine
sudo cp /usr/local/spine/etc/spine.conf.dist /usr/local/spine/etc/spine.conf
sudo sed -i "s/DB_Pass       cactiuser/DB_Pass       MyV3ryStr0ngPassword/ig" /usr/local/spine/etc/spine.conf

Step 10 – Remove File permissions

Now we can remove unnecessary file permissions again:

chmod -R 555 /var/www/html/cacti/resource
chmod -R 555 /var/www/html/cacti/scripts
chmod -R 550 /var/www/html/cacti/include/vendor/csrf

Step 11 – Cron Job

Cacti uses cron (scheduled task) to execute its polling process. It’s always a good idea to run this under a different user than root.

Let’s now add a new cron entry to your system for a 1-minute polling interval using the following command:

echo "*/1 * * * * apache php /var/www/html/cacti/poller.php &>/dev/null" >> /etc/cron.d/cacti

Need Commercial Support on how to install Cacti on RockyLinux 8 ? offer commercial Cacti support not only for Cacti itself, but also for several of the plugins ( e.g. Thold ).
There’s going to be an on-demand solution in the future. You can contact us for more details using the contact form.

If you require free support, please visit the cacti forum !