In this guide, you’ll learn to Install Cacti 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
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
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.
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;
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
Change the default password. Input a long password with mixed characters with one upper and lower case as well as special characters.
Accept License Agreement and click “Begin“
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.
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.
Choose the installation type you want. Primary server it is for this example. Click “Next” thereafter.
Directory permission checks. Click “Next“
It will suggest the directories where its critical binary files will be placed. Simply click on “Next“
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.
Choose default profile for poller and network details
Setup the templates you need and click “Next” to proceed forward
The wizard will do configuration checks. After it is done, click “Next“
Confirm installation by checking the radio button then click “Install” to begin the installation process.
Give it time to complete installing
After it is done, refresh your page and you should be presented with the login page. Input adimin and the new password you created.
And here we are!
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 :