RHEL BasedRocky Linux

How To Install Cacti on Rocky Linux 9

Install Cacti on Rocky Linux 9

In this tutorial, we will show you how to install Cacti on Rocky Linux 9. For those of you who didn’t know, Cacti is an open-source, web-based network monitoring and graphing tool designed as a front-end application for the open-source, industry-standard data logging tool RRDtool. Cacti gather performance metrics from servers and network devices and graph and store them for reporting and historical analysis.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Cacti monitoring tool on Rocky Linux. 9.


  • A server running one of the following operating systems: Rocky Linux 9.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Cacti on Rocky Linux 9

Step 1. The first step is to update your system to the latest version of the package list. To do so, run the following commands:

sudo dnf check-update
sudo dnf install dnf-utils
sudo dnf install net-snmp net-snmp-utils net-snmp-libs rrdtool

Step 2. Installing Apache.

By default, Apache is not available on the Rocky Linux 9 base repository. Now we install the latest version of Apache using dnf the command:

sudo dnf install httpd httpd-tools

You can start the httpd service and configure it to run on startup by entering the following commands:

sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl status httpd

To make your pages available to the public, you will have to edit your firewall rules to allow HTTP and HTTPS requests on your web server by using the following commands:

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

For additional resources on installing Apache, read the post below:

Step 3. Installing MariaDB.

By default, MariaDB is available on the Rocky Linux 9 base repository. Simply install the MariaDB package by using the dnf command:

sudo dnf install mariadb-server mariadb

After the installation is completed, start the service of the Database server and then enable the same, so that it could start itself automatically with the system reboot:

sudo systemctl restart mariadb
sudo systemctl status mariadb
sudo systemctl enable mariadb

By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script. you should read and below each step carefully which will set a root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB:


First, log into the MariaDB shell with the following command:


Now we create a database and user for Cacti with the following command:

MariaDB [(none)]> create database cactidb;
MariaDB [(none)]> GRANT ALL ON cactidb.* TO cacti@localhost IDENTIFIED BY 'your-strong-password';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit;

Then, import the MySQL test data timezone.sql file into the MySQL database:

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

After that, log into MySQL and grant cacti user to access the mysql.time_zone_name table:


Once logged in, run the following command to grant access:

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

For additional resources on installing MariaDB Database, read the post below:

Step 4. Installing PHP.

PHP is a popular scripting language that powers the dynamic content of millions of websites and apps. Now we run the commands below to install PHP:

sudo dnf epel-release
sudo dnf module enable php:remi-8.1

Once Remi PHP 8.1 module is enabled, you can now install PHP 8.1 and commonly used PHP extensions as follows:

sudo dnf install php php-cli php-fpm php-gd php-curl php-zip php-mbstring php-opcache php-intl php-mysqlnd

Check and verify the installed version:

php -v

For additional resources on installing PHP, read the post below:

Step 5. Installing Cacti on Rocky Linux 9.

Now run the following command below to install the Cacti monitoring tool:

sudo dnf install cacti

Then, import the default cacti database tables into the MariaDB cacti database you created above:

mysql -u root -p cactidb < /usr/share/doc/cacti/cacti.sql

Next, edit the Cacti configuration file and define your database settings:

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

Add the following configuration:

$database_type     = 'mysql';
$database_default  = 'cactidb';
$database_hostname = 'localhost';
$database_username = 'cacti';
$database_password = 'your-strong-password';
$database_port     = '3306';
$database_retries  = 5;
$database_ssl      = false;

Save and close the file, then create a Cron file for Cacti:

nano /etc/cron.d/cacti

Add the following line:

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

Step 6. Configure Apache.

Now create an Apache virtual host configuration:

nano /etc/httpd/conf.d/cacti.conf

Find the following lines:

Alias /cacti   /usr/share/cacti

<Directory /usr/share/cacti/>
        <IfModule mod_authz_core.c>
               	# httpd 2.4
                Require host localhost
        <IfModule !mod_authz_core.c>
               	# httpd 2.2
                Order deny,allow
                Deny from all
                Allow from localhost

And, Replace them with the following lines:

Alias /cacti    /usr/share/cacti

<Directory /usr/share/cacti/>
        <IfModule mod_authz_core.c>
               	# httpd 2.4
                Require all granted
        <IfModule !mod_authz_core.c>
               	# httpd 2.2
                Order deny,allow
                Deny from all
                Allow from all

Save and close the file, then restart the Apache and PHP-FPM service to apply the changes:

sudo systemctl restart httpd
sudo systemctl restart php-fpm

Step 7. Accessing Cacti Monitoring Web Interface.

Once successfully installed, open your web browser and access the Cacti installation wizard using the URL http://your-ip-address/cacti. You will be redirected to the following page:

Install Cacti on Rocky Linux 9

Log in with the default credentials shown:

Username: admin
Password: admin

Congratulations! You have successfully installed Cacti. Thanks for using this tutorial for installing the Cacti monitoring tool on your Rocky Linux 9 system. For additional help or useful information, we recommend you check the official Cacti website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button