How to Install Cacti on Ubuntu Server Latest

Cacti is an open-source network monitoring and graphing tool that can graph different data sources such as CPU usage, network bandwidth utilization, memory usage, and many others.

In this tutorial, we will be showing you how to install Cacti on your Ubuntu Server latest version.

Prerequisites

Before starting with the installation of Cacti, you need to have a few prerequisites installed on your server:

Step 1: Update your Ubuntu Server

You need to ensure that your Ubuntu system is up-to-date by running the following command:

sudo apt update
sudo apt upgrade

Step 2: Install Required Packages

Cacti requires several packages to be installed, such as SNMP, RRDtool, and PHP.

You can install them with the following command:

sudo apt install snmp snmpd rrdtool php php-cgi php-pear php-mysql libapache2-mod-php php-common php-gd php7.4-xml libphp-adodb

Step 3: Configure SNMP

To configure SNMP, open the /etc/snmp/snmpd.conf file using your favorite text editor.

sudo nano /etc/snmp/snmpd.conf

Add the following code to the end of the file:

view   systemonly  included   .1.3.6.1.2.1.1
view   systemonly  included   .1.3.6.1.2.1.25.1
rocommunity public  localhost 

After making the changes to the SNMP configuration file, save and close it.

Step 4: Create Cacti Database

Create a new database for Cacti using the following commands:

sudo mysql -u root -p
CREATE DATABASE cacti;
GRANT ALL PRIVILEGES ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'Your_Password_Here';

Replace Your_Password_Here with a strong password.

Step 5: Install Cacti

Now, we will install Cacti on Ubuntu Server. First, download the Cacti archive by running the following command:

wget https://www.cacti.net/downloads/cacti-1.2.16.tar.gz

Next, extract the downloaded archive using the following command:

sudo tar -zxvf cacti-1.2.16.tar.gz -C /var/www/html/

Then, navigate to the /var/www/html/cacti-1.2.16/ directory and rename the include/config.php.dist file to include/config.php.

cd /var/www/html/cacti-1.2.16/
sudo mv include/config.php.dist include/config.php

Edit the Cacti configuration file /var/www/html/cacti-1.2.16/include/config.php using your favorite text editor:

sudo nano /var/www/html/cacti-1.2.16/include/config.php

Locate the following line:

$database_password = '';

Set the password for the Cacti database by replacing '' with the password you set in step 4.

Step 6: Import Cacti MySQL Database

Import the Cacti MySQL database schema by running the following command:

sudo mysql -u cactiuser -p cacti < /var/www/html/cacti-1.2.16/cacti.sql

Step 7: Configure Cacti Cron Job

Cacti requires a Cron job to be set up to collect data at regular intervals. You can do this by running the following command:

sudo crontab -e

Add the following line at the end of the file:

*/5 * * * * /usr/bin/php /var/www/html/cacti-1.2.16/poller.php > /dev/null 2>&1

This will collect data every 5 minutes.

After making the changes, save and close the file.

Step 8: Configure Apache

Finally, you need to configure Apache to serve Cacti.

Create a new Apache configuration file for Cacti:

sudo nano /etc/apache2/sites-available/cacti.conf

Add the following lines to the file:

<VirtualHost *:80>
     ServerAdmin admin@example.com
     DocumentRoot /var/www/html/cacti-1.2.16/
     ServerName monitoring.example.com 
     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Replace admin@example.com with your email address, monitoring.example.com with your domain name or IP address.

Then, enable the new Apache configuration by running the following command:

sudo a2ensite cacti.conf

Restart Apache for the changes to take effect:

sudo systemctl restart apache2
sudo systemctl enable apache2

Conclusion

Congratulations! You have successfully installed Cacti on your Ubuntu Server. You can access it in your web browser using the URL http://server-ip/cacti/.

You can now start monitoring your network resources and generate graphs and reports based on the data collected.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!