How To Install and Configure Cacti on Debian 11

This tutorial intends to teach you How To Install and Configure Cacti on Debian 11.

Cacti is an open-source, network monitoring and graphing tool written in PHP/MySQL. It uses the RRDTool (Round-robin database tool) engine to store data and generate graphics and collects periodical data through Net-SNMP (an application suite to implement SNMP—Simple Network Management Protocol).

Install and Configure Cacti on Debian 11

To install the Cacti network monitoring tool, you need to log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide the Initial Server Setup with Debian 11.

Also, you need to have the LAMP Stack installed on your server. You can check our guide on How To Install the LAMP stack on Debian 11. You need to check the installation parts, not the whole article.

Now you can follow the steps below to complete this guide.

Set up PHP Extensions on Debian 11

Here you need to install some PHP extensions and dependencies on Debian 11 with the commands below:

sudo apt install php-{mysql,curl,net-socket,gd,intl,pear,imap,memcache,pspell,tidy,xmlrpc,snmp,mbstring,gmp,json,xml,common,ldap}
sudo apt install libapache2-mod-php

At this point, you need to configure PHP memory and execution time. To do this, open the php.ini file with your favorite text editor, here we use vi:

sudo vi /etc/php/*/apache2/php.ini

Find the lines below and change the values as shown below:

memory_limit = 512M
max_execution_time = 300

Also, find the line below and uncomment it by removing the “;” from the beginning of the line and setting it to your time zone.

date.timezone = US/Eastern

When you are done, save and close the file.

Then, open the PHP CLI php.ini file and set the time zone there as well:

sudo vi /etc/php/*/cli/php.ini
date.timezone = US/Eastern

When you are done, save and close the file.

Configure MariaDB for Cacti on Debian 11

At this point, you need to create a database and user for Cacti. Log in to your MariaDB shell with the command below:

sudo mysql -u root -p

From your MariaDB shell, run the command below to create the Cacti database, here we named it Cacti:

MariaDB [(none)]> CREATE DATABASE cacti DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;

Then, create the cacti user and grant all the privileges to the database user with the command below:

MariaDB [(none)]> GRANT ALL PRIVILEGES ON cacti.* TO 'cacti_user'@'localhost' IDENTIFIED BY 'strongpassword';

Flush the privileges and exit from MariaDB with the commands below:

MariaDB [(none)]> FLUSH PRIVILEGES; 
MariaDB [(none)]> EXIT;

Next, you need to populate MySQL’s TimeZone information with the following command:

sudo mysql -u root -p mysql < /usr/share/mysql/mysql_test_data_timezone.sql

At this point, you need to grant database user access to the MySQL TimeZone database and select permission. To do this, log in to your MariaDB shell and run the following commands:

sudo mysql -u root -p
MariaDB [(none)]> GRANT SELECT ON mysql.time_zone_name TO cacti_user@localhost;
MariaDB [(none)]> ALTER DATABASE cacti CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
MariaDB [(none)]> EXIT;

Now open the MariaDB file and add the lines below under the [mariadb] section for an optimized database:

sudo vi /etc/mysql/mariadb.conf.d/50-server.cnf

Also, add a # tag in front of these two lines available in the same file to make them unreadable:

#character-set-server = utf8mb4
#collation-server = utf8mb4_general_ci

When you are done, save and close the file.

Install SNMP and RRDTool

To work with Cacti on Debian 11, you need to install the SNMP and RRDTool. To do this, run the following command:

sudo apt install snmp snmpd rrdtool

Now you can follow the steps below to install the latest release of Cacti.

Set up Cacti Network Monitoring on Debian 11

At this point, you can clone the latest version of Cacti from Github.

First, install git on your server with the command below:

sudo apt install git

Then, clone Cacti from Github:

git clone -b 1.2.x

Next, you need to move the cacti files to your Web directory on Debian 11:

sudo mv cacti /var/www/html

Use the Cacti SQL configuration file to pre-populate the database created for it:

sudo mysql -u root cacti < /var/www/html/cacti/cacti.sql

Here you need to create a PHP configuration file for Cacti. The Configuration file is already present inside the copied Cacti folder, we just rename it with the commands below:

cd /var/www/html/cacti/include
cp config.php.dist config.php

Now, edit the config.php and add the Database details you have created for Cacti.

sudo vi config.php
$database_type = "mysql"; 
$database_default = "cacti"; 
$database_hostname = "localhost"; 
$database_username = "cacti_user"; 
$database_password = "strongpassword"; 
$database_port = "3306"; 
$database_ssl = false;

When you are done, save and close the file.

Next, give Apache user permission to access the Cacti folder in the Web root directory:

sudo chown -R www-data:www-data /var/www/html/cacti

To run the Cacti poller service in the background, you need to create a Cacti system service with the following command:

sudo vi /etc/systemd/system/cactid.service

Add the following content to the file:

Description=Cacti Daemon Main Poller Service

When you are done, save and close the file.

Then, create an environment file with the command below:

sudo touch /etc/default/cactid

Reload the system services:

sudo systemctl daemon-reload

Start and enable the Cacti service on Debian 11 with the given commands:

# sudo systemctl enable cactid
# sudo systemctl restart cactid

Verify that your service is active and running on your server:

sudo systemctl status cactid
● cactid.service - Cacti Daemon Main Poller Service
Loaded: loaded (/etc/systemd/system/cactid.service; enabled; vendor prese
Active: active (running) since Wed 2022-06-15 04:18:43 EDT; 47s ago
Process: 18738 ExecStart=/var/www/html/cacti/cactid.php (code=exited, stat
Main PID: 18746 (php)
Tasks: 1 (limit: 2340)
Memory: 15.7M
CPU: 182ms
CGroup: /system.slice/cactid.service
└─18746 php /var/www/html/cacti/cactid.php

Also, restart your Apache and MariaDB to apply the changes:

sudo systemctl restart apache2 mariadb

Access Cacti Web Interface

At this point, you can continue your Cacti installation from the web interface by typing your server’s IP address in your web browser followed by Cacti:


You will see the Cacti login screen. Enter the default username and password as admin and click Login.

Cacti login screen

Then, you need to change the current default password for Cacti and click save.

Change default cacti password

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

License agreement for Cacti

In the Next step, the installation wizard will check that all the required things for Cacti work are in place. If any of the requirements are not met the same will reflect on your screen. If we have to fulfill the same then only we will be able to move forward.

Pre-installation check for Cacti

On the next screen, you will see that by default let the “New Primary Server” be 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 to continue.

Cacti installation type

In the next step, the system will ensure all the necessary permissions required by Cacti to access files are set. Click next.

Directory permission checks for Cacti on Debian 11

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

Critical Binary Locations and Versions

Next, check the box next to the I have read this statement to acknowledge that you have read and understand this security concern and click Next.

Input Validation Whitelist Protection

After that, choose the default profile for poller and network details and click Next.

Cacti default profile

On the Template Setup, Please select the Device Templates that you wish to use after the Install and click Next.

Template setup for cacti on Debian 11

Confirm installation by checking the radio button then click “Install” to begin the installation process.

start Cacti installation on Debian 11

When it is completed, click on the Get Started button and you will see your Cacti dashboard.

Cacti dashboard on Debian 11

It is now time to add your devices and configure Cacti to start monitoring them. There is much more to do after you have your server running.

For more information, you can visit the Cacti Documentation page.


At this point, you learn to Install and Configure Cacti on Debian 11.

Hope you enjoy using it.

You may be interested in this article on the Orcacore website:

How To Install and Configure Cacti on AlmaLinux 8

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!