Install Cacti Monitoring Server on Debian 10 (Buster) using Nginx

Introduction

In this guide, you will learn to install Cacti monitoring server on Debian 10 (Buster) using Nginx reverse proxy. Cacti is a complete network graphics solution designed to take advantage of RRDTool’s data storage and graphics capabilities. Cactus provides out-of-the-box quick polling, advanced graphic templates, multiple data collection methods, and user management functions. All of this is packaged in an intuitive, easy-to-use interface that makes sense for LAN-sized installations and complex networks with thousands of devices.

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

Step 1: Install required packages

Installation requires dependencies. Make sure 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 command on a Debian 10 terminal to install PHP 7.3.

sudo apt -y install php php-common

Add PHP extension

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’s move on to creating a database for Cacti.

Log in to your database

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

Create database and cactus user

The default Cacti database data we will import later uses a database named cacti. Therefore, it would be wise to create a database with that name to simplify your work.

 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 users access to MySQL TimeZone database and select permissions

The Cactus Database login account (in this example, Cactus) 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

In this example, grant permissions to your user (e.g. cactiuser)

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 following lines below [mysqld] Optimize the database section

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

Add the following below [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's make sure that date.timezone in php.ini is set to the preferred time zone.

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

Down [Date] Untype the date.timezone line and add your time zone.

 [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, below [Date] Untype the date.timezone line and add your time zone.

[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 web server

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

Remove the default page loaded after a fresh install of Nginx

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

Create a file as shown and add the following to it

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

Paste and modify the following 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

Now we need to download the latest version of the Cacti package.

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

After downloading, unzip the cactus file

tar -zxvf cacti-latest.tar.gz

Move the file to our web root directory and change the directory name

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

Change ownership of cactus files

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

Import the default Cacti database data into the Cacti database.

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

Open the Cacti configuration file to enter the 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 completing the configuration, restart the web server.

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 crontab

$ sudo vim /etc/cron.d/cacti

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

This will cause the cactus to poll every five minutes.

Step 8: Web installer

Now go to the web installer and follow the instructions on the screen.

http: // IP or FQDN / cacti

This will load an installer similar to the following installer. Enter the default username and password, ie administrator with administrator

Change the default password. Enter a long password that contains mixed case and special characters.

Install Cacti Monitoring Server on Debian 10 (Buster) using Nginx

Accept the license agreement and click "Start"

Install Cacti Monitoring Server on Debian 10 (Buster) using Nginx

I absolutely love dark mode, so I had to change the default theme. If you want to use the default values, you don't have to do the same. Click "Start"start installation.

Install Cacti Monitoring Server on Debian 10 (Buster) using Nginx

It will check if the PHP and MySQL configuration we have performed meets its needs. Click "nextIf everything is green, thumbs up.

Install Cacti Monitoring Server on Debian 10 (Buster) using Nginx

Select the required installation type. In this example, it is the master server. Click "next".

Install Cacti Monitoring Server on Debian 10 (Buster) using Nginx

Directory permission check. Click "next"

Install Cacti Monitoring Server on Debian 10 (Buster) using Nginx

It will suggest the directory where its key binaries are placed. Just click "next"

Install Cacti Monitoring Server on Debian 10 (Buster) using Nginx

Read the statement carefully and select the radio button when you understand it. This is important because it involves server security. Click "next".

Install Cacti Monitoring Server on Debian 10 (Buster) using Nginx

Select the default profile for poller and network details

Install Cacti Monitoring Server on Debian 10 (Buster) using Nginx

Set the desired template and click "next"Keep going

Install Cacti Monitoring Server on Debian 10 (Buster) using Nginx

The wizard will perform a configuration check. When done, click "next"

Install Cacti Monitoring Server on Debian 10 (Buster) using Nginx

Confirm the installation by checking the radio button, then click "installation"To begin the installation process.

Install Cacti Monitoring Server on Debian 10 (Buster) using Nginx

Give it time to complete the installation

Install Cacti Monitoring Server on Debian 10 (Buster) using Nginx

When done, refresh your page and the login page should display. input value Adimin And the new password you created.

Install Cacti Monitoring Server on Debian 10 (Buster) using Nginx

We have arrived!

Install Cacti Monitoring Server on Debian 10 (Buster) using Nginx

in conclusion

It's time to add devices and configure Cacti to start monitoring them. After running the server, there are many other things to do. Some of them are provided in How to Import Templates on Cacti. We hope this guide was helpful to you. Thank you for your visit.

To give you more guidance:

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

Sidebar