How to Install and Configure Cacti on Ubuntu 22.04
Cacti is a network monitoring and graphing tool that uses SNMP to monitor network devices. Follow these steps to install Cacti on Ubuntu 22.04.
Step 1: Install Required Packages
First, install Apache, MariaDB, PHP, and required dependencies:
sudo apt install apache2 mariadb-server php php-mysql libapache2-mod-php -y
Step 2: Install SNMP and RRDTool
Install SNMP and RRDTool, which are required by Cacti:
sudo apt install snmp snmpd rrdtool -y
Step 3: Install Cacti
Install Cacti using the package manager:
sudo apt install cacti -y
Step 4: Configure MariaDB for Cacti
Run the secure installation script for MariaDB:
sudo mysql_secure_installation
Then, create a database for Cacti:
sudo mysql -u root -p -e "CREATE DATABASE cacti DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;"
sudo mysql -u root -p -e "GRANT ALL PRIVILEGES ON cacti.* TO 'cactiuser'@'localhost' IDENTIFIED BY 'yourpassword';"
sudo mysql -u root -p -e "FLUSH PRIVILEGES;"
Step 5: Configure Cacti
Import the default Cacti database schema:
sudo mysql -u cactiuser -p cacti < /usr/share/cacti/cacti.sql
Edit the Cacti configuration file to match your database settings:
sudo nano /etc/cacti/debian.php
Step 6: Set Up Cron Job
Enable the Cacti poller by adding a cron job:
echo "*/5 * * * * www-data php /usr/share/cacti/poller.php" | sudo tee -a /etc/cron.d/cacti
Step 7: Configure Apache for Cacti
Edit the Apache configuration for Cacti:
sudo nano /etc/apache2/sites-available/cacti.conf
Add the following lines:
Alias /cacti /usr/share/cacti
<Directory /usr/share/cacti>
Options +FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Enable the configuration and restart Apache:
sudo a2ensite cacti
sudo systemctl restart apache2
Step 8: Access Cacti Web Interface
Now, open a web browser and navigate to http://your-server-ip/cacti. Follow the installation wizard to complete the setup.
Conclusion
You have successfully installed and configured Cacti on Ubuntu 22.04. Your system is now ready for network monitoring.