Cacti is a popular network monitoring and graphing tool that allows you to monitor various network metrics, such as network traffic and bandwidth usage. In this article, we will show you how to install Cacti on Ubuntu 22.04.
Before we start, make sure that your system is up to date by running the following command:
sudo apt-get update
Next, we need to install some dependencies that are required by Cacti. We can do this by running the following command:
sudo apt-get install apache2 mariadb-server mariadb-client libapache2-mod-php php-mysql snmp snmpd
After the dependencies are installed, we need to create a database and a user for Cacti. To do this, we first need to log in to the MariaDB server using the following command:
mysql -u root -p
Enter your MariaDB root password when prompted, and you should be logged in to the MariaDB server. Now, we can create a database and a user for Cacti by running the following commands:
CREATE DATABASE cacti;
GRANT ALL PRIVILEGES ON cacti.* TO 'cacti'@'localhost' IDENTIFIED BY '<password>';
FLUSH PRIVILEGES;
Replace <password>
with the password that you want to use for the Cacti user.
Next, we need to download the latest version of Cacti from its official website. At the time of writing this article, the latest version is 1.2.15. You can download it by running the following command:
wget <https://www.cacti.net/downloads/cacti-1.2.15.tar.gz>
Once the download is complete, extract the downloaded file using the following command:
tar -xvf cacti-1.2.15.tar.gz
Next, move the extracted directory to the Apache web server’s document root directory. The default document root directory for Apache on Ubuntu is /var/www/html
. You can move the directory by running the following command:
sudo mv cacti-1.2.15 /var/www/html/cacti
Now, we need to import the Cacti database schema into the Cacti database that we created earlier. To do this, run the following command:
mysql -u cacti -p cacti < /var/www/html/cacti/cacti.sql
Enter the password that you set for the Cacti user when prompted.
Next, we need to configure the Cacti web interface. To do this, open the /var/www/html/cacti/include/config.php
file in a text editor and update the following lines:
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "<password>";
Replace <password>
with the password that you set for the Cacti user.
Save the file and exit.