How to Install Cacti Server Monitor on Ubuntu 24.04 or Newer
Welcome to the Greenhost.cloud blog! In today’s post, we will guide you through the process of installing Cacti, a powerful network monitoring tool, on Ubuntu 24.04 or newer. Cacti allows you to visualize network performance through graphs and charts, making it an essential tool for network administrators.
What is Cacti?
Cacti is an open-source network monitoring and graphing solution that leverages the power of RRDTool (Round Robin Database Tool). It provides a user-friendly web interface to manage and visualize data from various network devices, servers, and other elements. With Cacti, you can monitor everything from bandwidth usage to CPU load, making it an invaluable asset for maintaining optimal network performance.
Prerequisites
Before we start the installation process, ensure that you have the following:
- A server running Ubuntu 24.04 or newer.
- Root access or a user account with sudo privileges.
- A LAMP stack (Linux, Apache, MySQL/MariaDB, and PHP) is installed on your server.
If you haven’t set up a LAMP stack, you can follow these steps:
sudo apt update
sudo apt install apache2 mysql-server php php-mysql libapache2-mod-php php-cli php-gd php-rrd php-json
After installing the LAMP stack, make sure to secure your MySQL installation:
sudo mysql_secure_installation
Step 1: Install Required Dependencies
Cacti requires several PHP extensions and other packages to function properly. Install these dependencies by running:
sudo apt install snmp snmpd rrdtool php-xml php-mbstring php-pear php-dev
Step 2: Download and Install Cacti
Now, let’s download the latest stable release of Cacti. As of the time of writing, you can find the latest version on the Cacti website. Use the following commands to download and extract Cacti:
cd /var/www/html
sudo wget https://www.cacti.net/downloads/cacti-latest.tar.gz
sudo tar -zxvf cacti-latest.tar.gz
sudo mv cacti-* cacti
Step 3: Configure Cacti
Next, we need to configure Cacti. Start by setting the appropriate permissions for the Cacti directory:
sudo chown -R www-data:www-data /var/www/html/cacti
sudo chmod -R 755 /var/www/html/cacti
Now, we need to create a MySQL database for Cacti. Open the MySQL shell:
sudo mysql -u root -p
Inside the MySQL shell, run the following commands:
CREATE DATABASE cacti;
GRANT ALL PRIVILEGES ON cacti.* TO 'cactiuser'@'localhost' IDENTIFIED BY 'your_password';
FLUSH PRIVILEGES;
EXIT;
Note: Replace
your_password
with a strong password of your choice.
Next, import the default Cacti database:
sudo mysql -u cactiuser -p cacti < /var/www/html/cacti/cacti.sql
Step 4: Configure Cacti Settings
Edit the Cacti configuration file to set the database connection details:
sudo nano /var/www/html/cacti/include/config.php
Find the following lines and replace them with your database details:
$database_type = "mysql";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "your_password";
$database_name = "cacti";
Step 5: Configure SNMP
Cacti uses SNMP to gather data from network devices. Open the SNMP configuration file:
sudo nano /etc/snmp/snmpd.conf
Make sure to change the agentAddress
line to:
agentAddress udp:161:161
And set the community string by editing the following line (replace public
with your desired community string):
rocommunity public localhost
After saving your changes, restart the SNMP service:
sudo systemctl restart snmpd
Step 6: Set Up Apache for Cacti
We need to configure Apache to serve the Cacti application. Create a new configuration file:
sudo nano /etc/apache2/sites-available/cacti.conf
Add the following content:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/cacti
ServerName yourdomain.com
<Directory /var/www/html/cacti>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/cacti_error.log
CustomLog ${APACHE_LOG_DIR}/cacti_access.log combined
</VirtualHost>
Enable the Cacti site and the required Apache modules:
sudo a2ensite cacti
sudo a2enmod rewrite
sudo systemctl restart apache2
Step 7: Finalize Cacti Installation
Open your web browser and navigate to http://yourdomain.com
(replace with your server’s IP or domain). You should see the Cacti installation wizard. Follow the on-screen instructions to complete the installation.
Once the installation is complete, log in using the default credentials:
- Username: admin
- Password: admin
Make sure to change the default password after logging in for the first time.
Conclusion
Congratulations! You have successfully installed Cacti Server Monitor on Ubuntu 24.04 or newer. You can now start monitoring your network’s performance and generating insightful graphs and reports.
If you encounter any issues or have questions, feel free to leave a comment below. Happy monitoring!
For more tutorials and tips on server management and optimization, stay tuned to the Greenhost.cloud blog!