How to Install Cacti on Debian 11
Cacti is one of the most popular open-source, web-based network monitoring and graphing tool that you can use to keep track of your network performance in almost real-time.
Cacti can gather metrics from network devices, graph them, and store them for reporting and historical analysis. You can also configure Cacti to poll SNMP devices, traffic counters, routers, servers, etc.
In this post, we will see how to install Cacti on Debian 11.
Prerequisites
First, update the repository index.
sudo apt update
Install MariaDB Database
Install MariaDB database by following the below URL.
READ: How to Install MariaDB on Debian 11
Tuning Database
You will need to change few MariaDB settings for Cacti installation. So, edit the configuration file.
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
And then, add/update the below settings in the [mysqld] section.
collation-server = utf8mb4_unicode_ci character-set-server = utf8mb4 max_heap_table_size = 128M tmp_table_size = 32M join_buffer_size = 64M innodb_file_format = Barracuda innodb_large_prefix = 1 innodb_buffer_pool_size = 512MB 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
Install Apache & PHP Extensions
sudo apt install -y apache2 libapache2-mod-php php-xml php-ldap php-mbstring php-gd php-gmp php-mysql
PHP Settings
As a mandatory requirement, Cacti require below values in /etc/php/7.4/apache2/php.ini
and /etc/php/7.4/cli/php.ini
files, assuming that your system has PHP v7.4.
date.timezone = US/Central memory_limit = 512M max_execution_time = 60
Install SNMP
sudo apt install -y snmp php-snmp rrdtool librrds-perl
Restart MariaDB and Apache service.
sudo systemctl restart mariadb sudo systemctl restart apache2
Install Cacti on Debian 11
Create Database
First, log in to the MariaDB server.
sudo mysql -u root -p
Then, create a database for the Cacti installation.
create database cacti;
Grant permission to the newly created database.
GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cactipassword'; flush privileges; exit
You will need to allow the created database user (cactiuser) to have access to the mysql.time_zone_name table. To do that, first, import the mysql_test_data_timezone.sql to mysql database.
sudo mysql -u root -p mysql < /usr/share/mysql/mysql_test_data_timezone.sql
Then, log in to MySQL.
sudo mysql -u root -p
Grant the permission to database user (cactiuser).
GRANT SELECT ON mysql.time_zone_name TO cactiuser@localhost; flush privileges; exit
Download Cacti
Download the latest version of the Cacti package using the wget command.
wget https://www.cacti.net/downloads/cacti-latest.tar.gz
Extract the Cacti archive using the tar
command and move the extracted files to /opt directory.
tar -zxvf cacti-latest.tar.gz sudo mv cacti-1* /opt/cacti
Import the default Cacti database data to the newly created database.
sudo mysql -u root -p cacti < /opt/cacti/cacti.sql
Edit the Cacti config file to specify the database type, name, hostname, user, and password information.
sudo nano /opt/cacti/include/config.php
Make the changes according to your requirement.
/* make sure these values reflect your actual database/host/user/password */ $database_type = "mysql"; $database_default = "cacti"; $database_hostname = "localhost"; $database_username = "cactiuser"; $database_password = "cactipassword"; $database_port = "3306"; $database_ssl = false;
Edit the Apache configuration file to add a virtual host for Cacti.
sudo nano /etc/apache2/sites-available/cacti.conf
Use the following information in the above virtual host file.
Alias /cacti /opt/cacti <Directory /opt/cacti> Options +FollowSymLinks AllowOverride None <IfVersion >= 2.3> Require all granted </IfVersion> <IfVersion < 2.3> Order Allow,Deny Allow from all </IfVersion> AddType application/x-httpd-php .php <IfModule mod_php.c> php_flag magic_quotes_gpc Off php_flag short_open_tag On php_flag register_globals Off php_flag register_argc_argv On php_flag track_vars On # this setting is necessary for some locales php_value mbstring.func_overload 0 php_value include_path . </IfModule> DirectoryIndex index.php </Directory>
Enable the created virtual host.
sudo a2ensite cacti
Restart Apache services.
sudo systemctl restart apache2
Change the ownership of the Cacti directory to Apache user (www-data).
sudo chown -R www-data:www-data /opt/cacti/
Data Collection Frequency
Edit the crontab file.
sudo nano /etc/cron.d/cacti
Add the following entry in the cron to allow Cacti poller to poll every five minutes.
*/5 * * * * www-data php /opt/cacti/poller.php > /dev/null 2>&1
Setup Cacti
Visit the following URL to begin the installation of Cacti.
Login to Cacti to initiate the setup.
admin
.Follow the Cacti web installer to set up Cacti on your system.
- First, you must change the password of the admin user before you begin the setup. Ensure your password meets the minimum requirement.
- Accept the Cacti license agreement and then click Begin to continue.
- On the next page, Cacti will perform pre-installation checks. Since we have already configured the system for Cacti, the pre-check should be clean. If Cacti reports any issues, fix them and click the Refresh icon to get the latest pre-check report. Finally, click Next.
- Select New Primary Server as an installation type and then click Next.
- Cacti perform Directory Permission Checks on this page to report permission issues you may have in Cacti installation directories. If the report is clean, click Next.
- Cacti now check for Critical binary locations and versions required for installation. Ensure the report is green and then click Next.
- Click the checkbox of I have read this statement on the Input Validation Whitelist Protection page and then click Next.
- Update the Network Range if you want to enable network scanning. Also, Cron Interval is Every 5 Minutes as we already configured cron to poll every five minutes.
- Click Next on the Template Setup page.
- Then, click Next again on the Database Compliant page.
- Ensure you click Confirm Installation and then click Install.
In a minute or two, the Cacti installation will be complete. Click on the Get Started to take you directly to the Cacti dashboard.
Access Cacti
Open up a browser and visit the below URL.
Login to Cacti using the admin with the password you entered during the Cacti setup.
The Cacti Dashboard will look like below after your successful login.
You can go to Graphs >> Default Tree >> Local Linux Machine to see the graph of your Cacti server.
Conclusion
That’s All. I hope you have learned how to install Cacti on Debian 11. Now, the Cacti is ready to monitor remote Linux machines.