In this article, we will have explained the necessary steps to install and configure Cacti on Ubuntu 20.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo
privileges. All the commands in this tutorial should be run as a non-root user.
Cacti is an open-source platform for data monitoring that is completely PHP driven. It is designed as the front-end application for the Round-Robin database tool (RRDtool). It is used to get CPU load and network bandwidth utilization in a graph format.
Install Cacti on Ubuntu 20.04
Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.
sudo apt update sudo apt upgrade
Step 2. Install LAMP Stack on Ubuntu.
Cacti is built with PHP. You can host it like you would any other web app is written in PHP. So, you’re going to need to set Ubuntu up as either a LAMP server. If you haven’t done so already, use our traditional LAMP guide to set up Ubuntu to serve PHP before you continue.
Step 3. Download and Install Cacti.
Now download the latest version of Cacti by running the below command:
wget https://www.cacti.net/downloads/cacti-latest.tar.gz
Extract the Cacti archive using the tar command:
tar -zxvf cacti-latest.tar.gz sudo mv cacti-1* /opt/cacti
Step 4. Creating a MySQL database for Cacti.
Cacti uses the MySQL database to store all its data like posts, pages, users, plugins, and themes settings. Log in to your MySQL server with the following command and enter your MySQL root password:
mysql -u root -p
Once you’re in the MySQL console, create a new database:
CREATE DATABASE cactidb; GRANT ALL ON cactidb.* to 'ownclouduser'@'localhost' IDENTIFIED BY 'your-passwd'; FLUSH PRIVILEGES; exit;
Now, hit the given command to import the default DB data to the new cacti DB:
sudo mysql -u root -p cacti < /opt/cacti/cacti.sql
Then specify the DB type, DB name, hostname, user, and password info by editing the below file:
sudo nano /opt/cacti/include/config.php
Update to similar changes:
/* make sure these values reflect your actual database/host/user/password */ $database_type = "mysql"; $database_default = "cacti"; $database_hostname = "localhost"; $database_username = "osradar"; $database_password = "'your-passwd'"; $database_port = "3306"; $database_ssl = false;
Once done, create a crontab file to schedule the polling job:
sudo nano /etc/cron.d/cacti
Add the following scheduler entry in the crontab so that Cacti can poll every five minutes:
*/5 * * * * www-data php /opt/cacti/poller.php > /dev/null 2>&1
Step 5. Configuring Apache for Cacti.
Create a new virtual host configuration file for your Cacti, named your-domain.com.conf:
sudo nano /etc/apache2/sites-available/cacti.conf
And add the following content to the file:
Alias /cacti /opt/cacti <Directory /opt/cacti> Options +FollowSymLinks AllowOverride None <IfVersion >= 2.3> Require all granted </IfVersion> <IfVersion < 2.3> Order Allow,Deny Allow from all </IfVersion> AddType application/x-httpd-php .php <IfModule mod_php.c> php_flag magic_quotes_gpc Off php_flag short_open_tag On php_flag register_globals Off php_flag register_argc_argv On php_flag track_vars On # this setting is necessary for some locales php_value mbstring.func_overload 0 php_value include_path . </IfVersion> DirectoryIndex index.php </Directory>
For the new configuration to take effect, restart the Apache service by typing:
sudo a2ensite cacti.conf sudo a2enmod rewrite sudo systemctl restart apache2
Step 6. Completing the Cacti Installation.
Open your favorite web browser and go to http://your_domain/cacti.
Login to the Cacti installation wizard to set up the Cacti installation:
Username: admin
Password: admin
That’s all you need to do to install Cacti on Ubuntu 20.04 LTS Focal Fossa. I hope you find this quick tip helpful. For further reading on Cacti, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.