In this guide, you’ll learn to install Cacti monitoring server on Debian 10 (Buster) with Nginx reverse proxy. Cacti is a complete network graphing solution designed to harness the power of RRDTool’s data storage and graphing functionality. Cacti offer fast polling, advanced graph templating, multiple data acquisition methods, and user management features out of the box. All of this is wrapped in an intuitive, easy to use interface that makes sense for LAN-sized installations up to complex networks with thousands of devices.

Follow the following steps to get Cacti running in Debian 10 (Buster).

Step 1: Install Required Packages

There are dependency packages required for the installation. Ensure they are installed.

sudo apt update
sudo apt install software-properties-common
sudo apt install nginx
sudo apt install curl vim acl composer fping git graphviz imagemagick mariadb-client mariadb-server mtr-tiny nginx-full python-memcache python-mysqldb snmp snmpd whois php-snmp rrdtool librrds-perl

Step 2: Install PHP

Run the following commands on your Debian 10 terminal to install PHP 7.3.

sudo apt -y install php php-common

Add PHP Extensions

sudo apt -y install php-cli php-fpm php-json php-pdo php-mysql php-zip php-gd  php-mbstring php-curl php-xml php-pear php-bcmath php-gmp php-ldap

Step 3: Database Configuration

We installed MariaDB in step 1. Let us proceed to create a database for Cacti.

Login to your DataBase

sudo systemctl enable mysql
sudo systemctl restart mysql
sudo mysql -u root -p

Create Database and cacti user

The default Cacti database data we will import later uses a database named cacti. So it will be prudent to create a database with that name to make your work easier.

 CREATE DATABASE cacti;
 CREATE USER 'cactiuser'@'localhost' IDENTIFIED BY 'SafePassWord'; ## Make it strong
 GRANT ALL PRIVILEGES ON cacti.* TO 'cactiuser'@'localhost';
 FLUSH PRIVILEGES;
 EXIT

Grant database user access to the MySQL TimeZone database and select permission

Cacti database login account (cactiuser in this example) must have access to the MySQL TimeZone database. Provide the Cacti database account “select” access to the “time_zone_name” table in the “mysql” database, and populate MySQL’s TimeZone information before proceeding.

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

After that, log in to MariaDB.

sudo mysql -u root -p

Grant the permission to your user e.g cactiuser in this example

GRANT SELECT ON mysql.time_zone_name TO [email protected];
ALTER DATABASE cacti CHARACTER SET = 'utf8mb4'  COLLATE = 'utf8mb4_unicode_ci'
flush privileges;
exit

Open MariaDB file and add the lines below under [mysqld] section for an optimized database

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

Add the following under [mysqld]

[mysqld]
........
collation-server = utf8mb4_unicode_ci
character-set-server  = utf8mb4
max_heap_table_size = 128M
tmp_table_size = 64M
join_buffer_size = 64M
innodb_file_format = Barracuda
innodb_large_prefix = 1
innodb_buffer_pool_size = 1GB
innodb_buffer_pool_instances = 10
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

Restart MariaDB

sudo systemctl restart mysql

Step 4: Configure PHP-FPM

Let us ensure date.timezone is set in php.ini to a preferred time zone.

sudo vim /etc/php/7.3/fpm/php.ini

Under [Date] uncoment the date.timezone line and add your timezone.

 [Date]
 ; Defines the default timezone used by the date functions
 ; http://php.net/date.timezone
 date.timezone = Africa/Nairobi ## Input your Time zone
 max_execution_time = 70        ## Increase max_execution_time
sudo vim /etc/php/7.3/cli/php.ini

Like above, under [Date] uncoment the date.timezone line and add your timezone.

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Africa/Nairobi ## Input your Time zone
memory_limit = 512M            ## Increase memory_limit

Restart PHP-FPM

sudo systemctl restart php7.3-fpm

Step 5: Configure Nginx Webserver

Since we chose Nginx as our preferred web server, it is time to add configurations so that we can serve our Cacti pages.

Delete the default page that loads up after fresh installation of Nginx

sudo rm /etc/nginx/sites-enabled/default

Create a file as shown and add the following in it

sudo vim /etc/nginx/conf.d/cacticonfig.conf

Paste and modify below data.

server {
 listen      80;
 server_name example.com;
 root        /var/www/html;
 index       index.php;
 access_log  /var/www/html/log/cactiacess.log;
 error_log   /var/www/html/log/cacti.log;
 charset utf-8;
 gzip on;
 gzip_types text/css application/javascript text/javascript application/x-javascript image/svg xml text/plain text/xsd text/xsl text/xml image/x-icon;
 location / {
   try_files $uri $uri/ /index.php?$query_string;
  }
  location /api/v0 {
   try_files $uri $uri/ /api_v0.php?$query_string;
  }
  location ~ .php {
   include fastcgi.conf;
   fastcgi_split_path_info ^(. .php)(/. )$;
   fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
  }
  location ~ /.ht {
   deny all;
  }
 } 

Restart Nginx

sudo systemctl restart nginx

Step 6: Install Cacti

We will now need to download the latest version of Cacti package.

curl -O https://www.cacti.net/downloads/cacti-latest.tar.gz

After it is done downloading, extract the Cacti archive

tar -zxvf cacti-latest.tar.gz

Move the files to our web root directory and change the name of the directory

sudo mv cacti-1* /var/www/html/
sudo mv /var/www/html/cacti-*/ /var/www/html/cacti

Change ownership for the cacti files

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

Import the default Cacti database data to the Cacti database.

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

Open the Cacti configuration file to input database information.

sudo vim /var/www/html/cacti/include/config.php
 $database_type = "mysql";
 $database_default = "cacti";
 $database_hostname = "localhost";
 $database_username = "cactiuser";
 $database_password = "SafePassWord"; 
 $database_port = "3306";
 $database_ssl = false;

Restart Nginx

After you are done with the configuration, restart the webserver.

sudo systemctl restart nginx

Step 7: Edit the crontab file.

In order for Cacti to poll every few minutes, you may need to add the following in your crontab

$ sudo vim /etc/cron.d/cacti

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

That will cause Cacti to poll every five minutes.

Step 8: Web installer

Now head to the web installer and follow the on-screen instructions.

http:// IP or FQDN /cacti

That should load the installer similar to the one below. Enter default username and password which is admin and admin

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/02/echo/cacti-login-1-1024×557.png" data-ez ezimgfmt="rs rscb7 src ng ngcb7 srcset" height="373" src="data:image/svg xml,” width=”687″>

Change the default password. Input a long password with mixed characters with one upper and lower case as well as special characters.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/02/echo/cacti-login-2-1024×603.png" data-ez ezimgfmt="rs rscb7 src ng ngcb7 srcset" height="403" src="data:image/svg xml,” width=”685″>

Accept License Agreement and click “Begin

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/02/echo/cacti-accept-license-3.png" data-ez ezimgfmt="rs rscb7 src ng ngcb7 srcset" height="502" src="data:image/svg xml,” width=”678″>

I prefer dark mode by all means, so I had to change the default theme. You do not have to do the same if you prefer the default one. Click “Begin” to start the installation.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/02/echo/cacti-accept-license-change-to-dark-3.png" data-ez ezimgfmt="rs rscb7 src ng ngcb7 srcset" height="534" src="data:image/svg xml,” width=”690″>

It is going to check if the PHP and MySQL configurations we made meet the requirements it needs. Click “Next” if everything gives a green thumbs up.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/02/echo/cacti-pre-installation-check-4.png" data-ez ezimgfmt="rs rscb7 src ng ngcb7 srcset" height="508" src="data:image/svg xml,” width=”650″>

Choose the installation type you want. Primary server it is for this example. Click “Next” thereafter.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/02/echo/cacti-installation-type-5.png" data-ez ezimgfmt="rs rscb7 src ng ngcb7 srcset" height="505" src="data:image/svg xml,” width=”656″>

Directory permission checks. Click “Next

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/02/echo/cacti-directory-permissions-6.png" data-ez ezimgfmt="rs rscb7 src ng ngcb7 srcset" height="492" src="data:image/svg xml,” width=”638″>

It will suggest the directories where its critical binary files will be placed. Simply click on “Next

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/02/echo/cacti-binary-checks-7.png" data-ez ezimgfmt="rs rscb7 src ng ngcb7 srcset" height="496" src="data:image/svg xml,” width=”641″>

Read the statement carefully and check the radio button after you have understood it. This is important because it touches on the security of your server. Click “Next” thereafter.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/02/echo/cacti-whitelist-protection-statement-8.png" data-ez ezimgfmt="rs rscb7 src ng ngcb7 srcset" height="501" src="data:image/svg xml,” width=”646″>

Choose default profile for poller and network details

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/02/echo/cacti-default-profile-9.png" data-ez ezimgfmt="rs rscb7 src ng ngcb7 srcset" height="500" src="data:image/svg xml,” width=”647″>

Setup the templates you need and click “Next” to proceed forward

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/02/echo/cacti-template-setup-10.png" data-ez ezimgfmt="rs rscb7 src ng ngcb7 srcset" height="500" src="data:image/svg xml,” width=”638″>

The wizard will do configuration checks. After it is done, click “Next

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/02/echo/cacti-server-collation-11.png" data-ez ezimgfmt="rs rscb7 src ng ngcb7 srcset" height="491" src="data:image/svg xml,” width=”632″>

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

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/02/echo/cacti-confirm-installation-12.png" data-ez ezimgfmt="rs rscb7 src ng ngcb7 srcset" height="494" src="data:image/svg xml,” width=”638″>

Give it time to complete installing

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/02/echo/cacti-final-installation-13.png" data-ez ezimgfmt="rs rscb7 src ng ngcb7 srcset" height="492" src="data:image/svg xml,” width=”636″>

After it is done, refresh your page and you should be presented with the login page. Input adimin and the new password you created.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/02/echo/cacti-login-14.png" data-ez ezimgfmt="rs rscb7 src ng ngcb7 srcset" height="479" src="data:image/svg xml,” width=”637″>

And here we are!

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/02/echo/cacti-login-dashboard-15-1024×386.png" data-ez ezimgfmt="rs rscb7 src ng ngcb7 srcset" src="data:image/svg xml,”>

Conclusion

It is now time to add your devices and configure Cacti to start monitoring them. There is much more do after you have your server running. Some of them is provided in How to Import templates on Cacti. We hope the guide was informative and helpful. Thank you for visiting.

More guides for you :

How To Install Cacti on RHEL 8 / CentOS 8

How to Install and Configure Cacti on Ubuntu 18.04

Install and Configure Nagios 4 on RHEL 8 / CentOS 8

How To Install Zabbix Server on CentOS 8 / RHEL 8

Install and configure LibreNMS on Debian 10 with Nginx