What Is Cacti?
Cacti is an open-source network monitoring and graphing tool built on top of RRDtool. It’s designed to collect, store, and visualize time-series data from networks and systems.
What Cacti Does
- Polls data from devices using SNMP or scripts (e.g., CPU load, memory usage, interface traffic)
- Stores data efficiently in round-robin databases (RRDs)
- Generates graphs to visualize trends over time (hourly, daily, weekly, etc.)
- Provides dashboards to monitor performance, bandwidth, system health
Key Features
- Web-based interface
- Custom graph templates
- Device and data source management
- User access control
- Support for SNMPv1, v2c, and v3
- Scalable with distributed polling
Common Use Cases
- Monitoring switches, routers, firewalls
- Tracking server resource usage
- Watching bandwidth consumption
- Creating historical reports on network performance
Why Use Cacti?
- Free and open-source
- Highly customizable
- Good for small to medium networks
- No vendor lock-in
- Visual and historical insights for capacity planning and troubleshooting
If you’re managing infrastructure and need insight over time, Cacti gives you the control and flexibility to track just about anything that can produce metrics.
This guide walks you through the steps to install and configure Cacti on AlmaLinux VPS from scratch.
Prerequisites
Before you start, make sure:
- You’re using AlmaLinux 8 or AlmaLinux 9
- You have sudo/root access
- Your system is up-to-date
- You have a LAMP stack installed (Apache, MariaDB, PHP)
- SELinux is either configured properly or temporarily set to permissive during setup
Install and Configure Cacti on AlmaLinux VPS
To install and configure Cacti on AlmaLinux VPS, follow the steps provided:
-
Update the System
sudo dnf update -y
Install essential tools:
sudo dnf install -y wget vim bash-completion
-
Install Apache, MariaDB, and PHP
sudo dnf install -y httpd mariadb-server php php-mysqlnd php-snmp php-gd php-xml php-mbstring php-json php-session
Start and enable services:
sudo systemctl enable --now httpd mariadb
Allow HTTP/S through the firewall:
sudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --reload
-
Secure MariaDB
Run the secure installation script:
sudo mysql_secure_installation
Follow the prompts:
- Set a root password
- Remove anonymous users
- Disallow root login remotely
- Remove test database
- Reload privileges
-
Create Cacti Database
mysql -u root -p
Inside MySQL:
CREATE DATABASE cacti; GRANT ALL PRIVILEGES ON cacti.* TO 'cactiuser'@'localhost' IDENTIFIED BY 'yourStrongPassword'; FLUSH PRIVILEGES; EXIT;
-
Install SNMP and RRDtool
Cacti relies on SNMP for data collection:
sudo dnf install -y net-snmp net-snmp-utils rrdtool
Start and enable SNMP:
sudo systemctl enable --now snmpd
-
Install Cacti
Enable EPEL and Cacti packages:
sudo dnf install -y epel-release sudo dnf install -y cacti
-
Import Default Database
mysql -u cactiuser -p cacti < /usr/share/doc/cacti/cacti.sql
-
Configure Cacti Settings
Edit
/etc/cacti/db.php
:$database_type = "mysql"; $database_default = "cacti"; $database_hostname = "localhost"; $database_username = "cactiuser"; $database_password = "yourStrongPassword";
Ensure Apache has access:
sudo chown -R apache:apache /var/lib/cacti/rra /var/lib/cacti/log
-
Configure Apache for Cacti
Edit
/etc/httpd/conf.d/cacti.conf
:<Directory /usr/share/cacti/> Require all granted </Directory>
Restart Apache:
sudo systemctl restart httpd
-
Configure Cron for Polling
Enable polling every 5 minutes:
sudo vi /etc/cron.d/cacti
Uncomment or add the line:
*/5 * * * * apache /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1
-
SELinux Configuration
If SELinux is enforcing, run:
sudo setsebool -P httpd_can_connect_db 1 sudo chcon -R -t httpd_sys_rw_content_t /var/lib/cacti/rra /var/lib/cacti/log
Or temporarily set to permissive:
sudo setenforce 0
-
Web Installer
Navigate to:
http://your-server-ip/cacti
Follow the web-based installation wizard:
- Verify pre-install checks
- Confirm database connection
- Set admin credentials
- Import templates
-
Final Tweaks
Log in using the default credentials:
- Username: admin
- Password: admin (you’ll be prompted to change it)
Once inside:
- Add devices for monitoring
- Configure SNMP community strings
- Review graphs under “Graph View”
-
Secure Cacti with HTTPS via Let’s Encrypt
Using HTTPS ensures encrypted traffic between users and your Cacti interface. We’ll use Certbot with Apache to install a free TLS certificate from Let’s Encrypt.
-
Install Certbot and Apache plugin
sudo dnf install -y certbot python3-certbot-apache
-
Obtain and Install the SSL Certificate
Replace
yourdomain.com
with your actual domain name:sudo certbot --apache -d yourdomain.com
Follow the prompts:
- Choose whether to redirect HTTP to HTTPS (recommended: select the redirect option)
- Certbot will automatically configure Apache for SSL
-
Test SSL Configuration
Visit:
https://yourdomain.com/cacti
You should see the Cacti login page with a secure padlock in the browser.
-
Automate SSL Renewal
Let’s Encrypt certificates expire every 90 days. Add a cron job or systemd timer to handle this automatically:
sudo systemctl enable --now certbot-renew.timer
You can also test the renewal process manually:
sudo certbot renew --dry-run
By securing Cacti with HTTPS, you ensure that sensitive monitoring data — like device configurations, login credentials, and performance graphs — are encrypted in transit. This step is critical for security, especially if you’re accessing your dashboard over the public internet.
-
-
Troubleshooting Tips
- Check logs in
/var/log/httpd/
for web errors. - Use
php -m
to ensure required PHP modules are installed. - Ensure timezones match (
/etc/php.ini
,/etc/cacti/global.php
). - Cacti graphs not showing? Check
/usr/share/cacti/poller.php
output manually.
sudo -u apache php /usr/share/cacti/poller.php
- Check logs in
Conclusion
You now know how to install and configure Cacti on AlmaLinux VPS. This setup provides a solid foundation for network monitoring and performance graphing. With SNMP in place, you can start graphing metrics for routers, switches, servers, and any SNMP-enabled device.
For production environments, secure your installation further:
- Stronger MySQL and web access policies
- SELinux set back to enforcing with proper contexts