Install Cacti on Ubuntu 24.04: Best Network Monitoring and Graphing Tool
This tutorial aims to teach you how to install Cacti on Ubuntu 24.04. In simple words, Cacti is a web-based network monitoring and graphing tool designed as a front-end application for the RRDTool (Round Robin Database Tool). It is widely used for monitoring network traffic, system performance, and server statistics.
Cacti performance data from various devices (like routers, switches, and servers) stores the data in a database, uses RRDTool to generate time-based graphs, and presents everything through a web interface. Here are the best features of Cacti:
- User-Friendly Interface: Offers an intuitive web interface for easy navigation and management.
- Customizable Graphs: Allows creating custom graphs with various data sources and visual options.
- Device Monitoring: Supports monitoring a wide range of network devices and servers.
- Alerting: Provides alerting capabilities to notify administrators of critical events.
- Template-Based: Uses templates for easy device and graph configuration.
- Plugin Architecture: Extensible with plugins for added functionality.
- Data Collection: Gathers data through SNMP, scripts, and other methods.
You can now proceed to the guide steps below on the Orcacore website to see the common usage of Cacti on Ubuntu 24.04 and start the installation process.
Ubuntu 24.04 supports the latest versions of PHP, MariaDB/MySQL, Apache/Nginx, and SNMP tools, which Cacti relies on. Here is how you can typically use Cacti on Ubuntu 24.04:
- Network Traffic Analysis: Monitor network bandwidth usage and identify traffic patterns.
- Server Performance Monitoring: Track CPU usage, memory utilization, disk I/O, and other server metrics.
- Application Monitoring: Monitor the performance of web servers, databases, and other applications.
- Device Health Monitoring: Monitor the status and health of network devices such as routers, switches, and firewalls.
- Custom Monitoring: Implement custom scripts to monitor specific metrics or applications.
Now that you have understood the usage of Cacti, you can proceed to the next steps to start Cacti installation on Ubuntu 24.04. Let’s start with the requirements you need for your Cacti monitoring setup on Ubuntu 24.04.
Also, you can check the guide steps in the Video tutorial:
First, you must have access to your Ubuntu 24.04 as a non-root user with sudo privileges and set up a basic UFW firewall. For this purpose, you can check the following articles:
Create a Sudo User on Ubuntu 24.04
Install and Enable UFW on Ubuntu 24.04
In this guide, we want to install Cacti with LAMP Stack. So you must set up the LAMP stack on Ubuntu 24.04. To do this, you can check this guide on the LAMP Stack Installation on Ubuntu 24.04.
Install and Configure Cacti on Ubuntu 24.04
Once you are done with the requirements, you can proceed to the following steps to configure PHP, MariaDB, and start Cacti installation on Ubuntu 24.04. Let’s see what we should do.
1. Configure PHP Settings for Cacti
First, you must install the required PHP extensions and dependencies. To do this, run the following commands:
# sudo apt install php-{mysql,curl,net-socket,gd,intl,pear,imap,memcache,pspell,tidy,xmlrpc,snmp,mbstring,gmp,json,xml,common,ldap} -y
# sudo apt install libapache2-mod-php -y
Then, you must edit the Apache php.ini file to configure memory limits, execution time, and timezone. Open the file with your desired text editor, like Vi Editor or Nano Editor:
sudo vi /etc/php/*/apache2/php.ini
In the file, look for the following lines and change their values as shown below:
memory_limit = 512M
max_execution_time = 300
Also, find the date.timezone line and uncomment it by removing the “;” from the beginning of the line and setting it to your time zone:
date.timezone = <mark>**your-timezone**</mark>
Once you are done, save and close the file.
Note: You can find your timezone by using the following command:
timedatectl
**<mark>Example Output</mark>**
Time zone: Etc/UTC
Next, open the CLI php.ini file and set the time zone there as well:
sudo vi /etc/php/*/cli/php.ini
Look for the following line and uncomment it by removing the “;” from the beginning of the line and setting it to your time zone:
date.timezone = <mark>**your-timezone**</mark>
Save and close the file when you are finished.
2. Configure MariaDB Settings For Cacti
At this point, you must log in to your MariaDB shell that you have set up from the LAMP Stack installation, and create a database and a user. To do this, run the command below:
sudo mysql -u root -p
From your MariaDB shell, run the commands below with your desired credentials to create a database and user, and give the user all privileges:
**<mark>MariaDB [(none)]></mark>** CREATE DATABASE <mark>**cactidb**</mark> DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
**<mark>MariaDB [(none)]></mark>** GRANT ALL PRIVILEGES ON <mark>**cactidb**</mark>.* TO '<mark>**cactiuser**</mark>'@'localhost' IDENTIFIED BY '<mark>**strongpassword**</mark>';
Once you are done, flush the privileges and exit from the MariaDB shell with the following commands:
**<mark>MariaDB [(none)]></mark>** FLUSH PRIVILEGES;
**<mark>MariaDB [(none)]></mark>** EXIT;
Populate MySQL TimeZone Information Ubuntu
At this point, you must populate MySQL TimeZone information with the following command:
sudo mysql -u root -p mysql < /usr/share/mysql/mysql_test_data_timezone.sql
Enter your MySQL root password when prompted. Once it is completed, you will not get information in your output.
Now log in to your MariaDB shell and run the following commands to grant database user access to the MySQL TimeZone database and select permission:
sudo mysql -u root -p
**<mark>MariaDB [(none)]></mark>** GRANT SELECT ON mysql.time_zone_name TO <mark>**cactiuser**</mark>@localhost;
**<mark>MariaDB [(none)]></mark>** ALTER DATABASE <mark>**cactidb**</mark> CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
**<mark>MariaDB [(none)]></mark>** FLUSH PRIVILEGES;
**<mark>MariaDB [(none)]></mark>** EXIT;
MariaDB server-specific Settings
At this point, you must edit the MariaDB configuration 50-server.cnf file to set server-specific settings like buffer sizes, connection limits, and storage engine options:
sudo vi /etc/mysql/mariadb.conf.d/50-server.cnf
In the file, add the lines below under the [mariadb] section for an optimized database:
innodb_file_format=Barracuda
innodb_large_prefix=1
collation-server=utf8mb4_unicode_ci
character-set-server=utf8mb4
innodb_doublewrite=OFF
max_heap_table_size=128M
tmp_table_size=128M
join_buffer_size=6M
sort_buffer_size=4M
innodb_buffer_pool_size=2G
innodb_flush_log_at_timeout=3
innodb_read_io_threads=32
innodb_write_io_threads=16
innodb_io_capacity=5000
innodb_io_capacity_max=10000
innodb_buffer_pool_instances=9
It will look like this:

Also, add a hashtag in front of the following two lines available in the same file to make them unreadable:
#character-set-server = utf8mb4
#collation-server = utf8mb4_general_ci
It will look like this:

Once you are done, save and close the file.
3. Install SNMP and RRDTool for Cacti
As you know, Cacti uses RRDTool and SNMP. So you must install SNMP and RRDTool on Ubuntu 24.04 with the following command:
sudo apt install snmp snmpd rrdtool -y
Now that you are done with configuring PHP and MariaDB settings, you can proceed to the next step to install Cacti on Ubuntu 24.04.
4. Download Cacti on Ubuntu 24.04 from GitHub
At this point, you can install Cacti by cloning it from GitHub. First, install git on Ubuntu 24.04 with the command below:
sudo apt install git -y
Then, use the following command to clone the latest Cacti version from GitHub:
git clone -b 1.2.x https://github.com/Cacti/cacti.git
Once it is done, you will get the following output:

Next, you must move the cacti files to your Web directory with the following command:
sudo mv cacti /var/www/html
5. Cacti Configuration on Ubuntu 24.04
At this point, use the Cacti SQL configuration file to pre-populate the database created for it. To do this, run the command below:
sudo mysql -u root <mark>cactidb</mark> < /var/www/html/cacti/cacti.sql
Now, you must create a PHP configuration file for Cacti. The Configuration file is already present inside the copied Cacti folder. We rename it with the commands below:
# cd /var/www/html/cacti/include
# cp config.php.dist config.php
Then, edit the config.php and add the Database credentials you have created for Cacti:
sudo vi config.php
Add your database name, user name, and password:
$database_type = "mysql";
$database_default = "<mark>**cactidb**</mark>";
$database_hostname = "localhost";
$database_username = "<mark>**cactiuser**</mark>";
$database_password = "<mark>**strongpassword**</mark>";
$database_port = "3306";
$database_ssl = false;
It will look like this:

Once you are done, save and close the file. Finally, give Apache user permission to access the Cacti folder in the Web root directory with the command below:
sudo chown -R www-data:www-data /var/www/html/cacti
6. Run Cacti As a System Service on Ubuntu 24.04
To run Cacti as a service, you must create a systemd unit file for it. To do this, you can run the following command:
sudo vi /etc/systemd/system/cactid.service
Add the below content to the file:
[Unit]
Description=Cacti Daemon Main Poller Service
After=network.target
[Service]
Type=forking
User=www-data
Group=www-data
EnvironmentFile=/etc/default/cactid
ExecStart=/var/www/html/cacti/cactid.php
Restart=always
RestartSec=5s
[Install]
WantedBy=multi-user.target
Save and close the file. Then, create an environment file for the Cacti service with the following command:
sudo touch /etc/default/cactid
Reload the system service to apply the changes, and then start and enable Cacti with the following commands:
# sudo systemctl daemon-reload
# sudo systemctl enable cactid
# sudo systemctl restart cactid
Verify your Cacti service is active and running with the command below:
sudo systemctl status cactid
In your output, you will see:

Finally, restart Apache and MariaDB to apply the changes:
sudo systemctl restart apache2 mariadb
7. Install Cacti on Ubuntu 24.04 from Web Interface
At this point, you can continue your Cacti setup from the web interface. From your desired web browser, open the following URL to access the Cacti dashboard:
http://<mark>your-server-IP-address</mark>/cacti/
You will see the Cacti login screen. In the username and password fields, enter admin and press Login.

Here, you must change the Admin password for more security. Enter the admin’s current password and set your desired password, and click Save.

Next, you will see the license agreement screen. Select your desired theme, language, accept the GPL License Agreement, and click Begin.

The installation wizard will check all the required things for Cacti to work correctly on Ubuntu 24.04. If everything is OK, as shown below, click Next.

Now you will see “New Primary Server” selected because it is an initial server that is going to monitor other devices. Also, check your local database connection information. If everything is correct, click Next.

After that, the system will ensure all the necessary permissions required by Cacti to access files are set correctly on Ubuntu 24.04. If everything is fine, click Next.

Then, you will see the Critical Binary Locations and Versions screen. Make sure all of these values are correct and click Next.

Now choose I have read this statement to acknowledge and click Next.

Choose the Default Profile and Network for Cacti and click Next. You can accept the default options.

Now, select the Device Templates that you wish to use after the installation and click Next.

Read the details about your Server, database, and table setup, and click Next.

Finally, confirm the Cacti installation and click Install.

Access Cacti Monitoring Dashboard
Once your installation is completed, click Get Started.

Now you have accessed your Cacti monitoring dashboard on Ubuntu 24.04:

It is now time to add your devices and configure Cacti to start monitoring them. Let’s see how you can add a new device to Cacti.
Add a New Device To Cacti
From the Cacti dashboard, in the left-hand menu, click Create and select New Device.

From there, add the following options:
- Description: The name of your device.
- Hostname: The IP address or hostname of the device.
- Host Template: Choose a template that matches your device type.
- SNMP Version: Select the SNMP version supported by your device.
- SNMP Community: Enter the SNMP community string (usually "public" for read-only access).
