Cacti

Apache - PHP

Main Repo
Setting Up

Configure MariaDB

Edit this file
sudo vim /etc/mysql/mariadb.conf.d/50-server.cnf
Add this to the end of the file
collation-server = utf8mb4_unicode_ci
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 = 512M
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 mariadb
Restart Apache
sudo systemctl restart apache2

Configure PHP

Edit Server config file
sudo vim /etc/php/7.4/apache2/php.in
Add this
date.timezone = US/Central
memory_limit = 512M
max_execution_time = 60
Edit the CLI config file
sudo vim /etc/php/7.4/cli/php.ini
Add this to the file
date.timezone = US/Central
memory_limit = 512M
max_execution_time = 60

Configure Database

Edit the config file
sudo vim /opt/cacti/include/config.php
Write your actual values
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";
$database_port = "3306";
$database_ssl = false;

Create crontab job

Edit this file
sudo vim /etc/cron.d/cacti
Scheduler entry
*/5 * * * * www-data php /opt/cacti/poller.php > /dev/null 2>&1

Create Log file

Use touch
sudo touch /opt/cacti/log/cacti.log

Create Database

create database cacti;
GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'cacti';
flush privileges;
exit
Login commands
sudo mysql -u root -p
sudo mariadb -u <user> -pL
Give writetable permissions to user
sudo chown -R www-data:www-data /opt/cacti/
Add a new site
Edit the config file
sudo vim /etc/apache2/sites-available/cacti.conf
Use this configuration
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 site
sudo a2ensite cacti

Last updated