How to Install Cacti 1.2 on AlmaLinux 9 or Rocky Linux 9
Install Cacti 1.2.31 on AlmaLinux 9 or Rocky Linux 9 with Apache, PHP 8.3 and MariaDB 10.11, then schedule the poller and finish in the web installer.
Cacti is a web application that polls devices over SNMP, stores the results in RRDtool files and draws graphs from them. This guide installs Cacti 1.2.31 on AlmaLinux 9 or Rocky Linux 9 with Apache, MariaDB and PHP, sets up the database and the poller, and finishes in the web installer. The same steps work on RHEL 9 and CentOS Stream 9.
CentOS 7 reached end of life in June 2024, and Cacti 1.1 is no longer maintained. The current 1.2 series has stricter requirements than the packages a default RHEL 9 installation provides: Cacti 1.2.31 needs PHP 8.1 or newer and MariaDB 10.6.28 or newer (or MySQL 8.0), while the default versions on the RHEL 9 family are PHP 8.0 and MariaDB 10.5. Both are solved below by enabling newer module streams from the distribution's own AppStream repository, so no third-party repositories are needed.
Requirements
- A server running AlmaLinux 9 or Rocky Linux 9 with current updates. The Cacti documentation suggests 2 CPU cores, 4 GB RAM and SSD storage for a small installation.
- A user with
sudorights. - The example server address is
203.0.113.10.
Step 1: Install Apache and PHP
List the PHP streams your release offers:
sudo dnf module list php
Enable a stream that is 8.1 or newer. PHP 8.3 is used here; pick 8.2 if 8.3 is not listed on your minor release:
sudo dnf module reset php
sudo dnf module enable php:8.3
Install Apache, PHP and the extensions Cacti requires:
sudo dnf install -y httpd php php-common php-bcmath php-cli \
php-mysqlnd php-gd php-gmp php-intl \
php-ldap php-mbstring \
php-pdo php-pear php-snmp php-process \
php-xml php-zip
Set the PHP time zone. Edit /etc/php.ini, find the date.timezone line, remove the leading semicolon and set your zone:
date.timezone = Europe/Berlin
On the RHEL 9 family Apache runs PHP through PHP-FPM. Enable and start both services:
sudo systemctl enable --now httpd php-fpm
Step 2: Install and configure MariaDB
Enable the MariaDB 10.11 stream and install the server. If dnf module list mariadb shows a newer stream on your system, you can enable that one instead:
sudo dnf module enable mariadb:10.11
sudo dnf install -y mariadb-server mariadb
sudo systemctl enable --now mariadb
Secure the installation. Set a root password and answer yes to removing anonymous users, the remote root login and the test database:
sudo mysql_secure_installation
Cacti needs the utf8mb4 character set and a few InnoDB settings. Create /etc/my.cnf.d/cacti.cnf with this content, which follows the base configuration in the Cacti documentation:
[mysqld]
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
max_allowed_packet = 16777777
join_buffer_size = 32M
innodb_file_per_table = ON
innodb_buffer_pool_size = 250M
innodb_flush_log_at_trx_commit = 2
These are starting values; the web installer later recommends values that fit your server's memory. Restart MariaDB and load the time zone tables, which Cacti requires:
sudo systemctl restart mariadb
mysql_tzinfo_to_sql /usr/share/zoneinfo | sudo mysql -u root mysql
Step 3: Install RRDtool and SNMP
sudo dnf install -y rrdtool net-snmp net-snmp-utils
If you want to graph this server itself, also enable its SNMP agent with sudo systemctl enable --now snmpd.
Step 4: Download Cacti
Download the release archive from cacti.net and move it into the web root:
cd /tmp
sudo dnf install -y wget tar
wget https://www.cacti.net/downloads/cacti-1.2.31.tar.gz
tar -zxf cacti-1.2.31.tar.gz
sudo mv -v cacti-1.2.31 /var/www/html/cacti
Check the Cacti download page for a newer 1.2.x release before you start and adjust the file name if there is one.
Step 5: Create the database
Open the MariaDB shell as root:
sudo mysql -u root
Create the database and a user, and allow that user to read the time zone table. Replace the password with your own:
CREATE DATABASE IF NOT EXISTS cacti CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'cactiuser'@'localhost' IDENTIFIED BY 'your_cacti_password';
GRANT ALL PRIVILEGES ON cacti.* TO 'cactiuser'@'localhost';
GRANT SELECT ON mysql.time_zone_name TO 'cactiuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Import the default schema:
sudo mysql -u root cacti < /var/www/html/cacti/cacti.sql
Step 6: Configure Cacti
Create the configuration file from the template:
sudo cp -v /var/www/html/cacti/include/config.php.dist /var/www/html/cacti/include/config.php
Edit /var/www/html/cacti/include/config.php and set the database fields:
$database_type = 'mysql';
$database_default = 'cacti';
$database_hostname = 'localhost';
$database_username = 'cactiuser';
$database_password = 'your_cacti_password';
$database_port = '3306';
Give the web server user ownership of the directories Cacti writes to:
cd /var/www/html/cacti
sudo chown -R apache:apache rra/ log/ cache/ resource/ scripts/ include/config.php
SELinux is enforcing by default and blocks Apache from writing below /var/www/html. Label the writable directories instead of switching SELinux off:
sudo dnf install -y policycoreutils-python-utils
sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/cacti/(rra|log|cache|resource|scripts)(/.*)?"
sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/cacti/include/config.php"
sudo restorecon -Rv /var/www/html/cacti
Step 7: Schedule the poller
The poller collects data every five minutes. Create /etc/cron.d/cacti with one line:
*/5 * * * * apache php /var/www/html/cacti/poller.php &>/dev/null
Cacti also ships a cactid systemd unit in /var/www/html/cacti/service/ that can run the poller instead of cron. Use one method, not both.
Step 8: Open the firewall and run the web installer
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload
sudo systemctl restart php-fpm httpd
Browse to http://203.0.113.10/cacti/ and sign in with the user name admin and the password admin. Cacti forces you to set a new password immediately. The installer then runs a pre-installation check and lists every PHP or MariaDB setting it wants changed, with the recommended value. Adjust /etc/php.ini or /etc/my.cnf.d/cacti.cnf as requested, restart php-fpm or mariadb, and reload the page until the checks pass. Accept the default paths for RRDtool, PHP and the SNMP tools, choose the new primary server installation type, select the device templates you need and finish the installation.
Verify that polling works
Add a device under Console → Create → New Device with its host name, SNMP version and community, then create graphs for it. After two polling cycles (about ten minutes) the graphs start to show data. If they stay empty, look at /var/www/html/cacti/log/cacti.log and run the poller once by hand to see its output:
sudo -u apache php /var/www/html/cacti/poller.php --force
If the page does not load or files cannot be written, check for SELinux denials with sudo ausearch -m avc -ts recent. For anything reachable from the internet, put the site behind HTTPS and limit access to the addresses that need it. The Cacti documentation includes an Apache TLS virtual host example and a hardening guide.
Frequently asked questions
Do I need Spine?
No. Cacti's built-in PHP poller, cmd.php, is sufficient for a small number of devices. Spine is a separate poller written in C that you compile yourself; it becomes worthwhile when a polling cycle no longer finishes within the five-minute interval. Its version should match the Cacti version.
Is Composer required?
Not for a normal installation. The Cacti requirements page states that pre-packaged releases include the vendor libraries, and that Composer is only needed when you install from source or from the development branch.
How do I upgrade later?
Switch off data collection under Settings → Poller, back up include/config.php, dump the database with mariadb-dump and archive the Cacti directory. Unpack the new release and copy it over the existing installation, set the ownership of rra/ and log/ to apache again, then open the web interface and follow the on-screen database upgrade. Re-enable polling when it is done.