How to configure and install cacti on Ubuntu_linux
How to configure and install cacti on Ubuntu_linux
Prerequisites
● A server running Ubuntu
● A root Privilege password is required to configure the cacti server.
Getting Started
Before starting, it is a good idea to update all system packages to the latest version. You can
update them with the following command:
apt-get update -y
Once all the packages are updated, install other required dependencies by running the following
command:
apt-get install snmp php-snmp rrdtool librrds-perl unzip curl git gnupg2 -y
Once all the dependencies are installed, you can proceed to the next step.
After installing all the packages, edit the php.ini file and make some changes:
nano /etc/php/7.4/apache2/php.ini
Change the following lines: and time zong according your country timezone date and time
memory_limit = 512M
max_execution_time = 60
date.timezone = Asia/Kolkata
Save and close the file then edit another php.ini file and make some changes:
nano /etc/php/7.4/cli/php.ini
Change the following lines:
memory_limit = 512M
max_execution_time = 60
date.timezone = Asia/Kolkata
Save and close the file when you are finished. Then, restart the Apache service to apply the
changes:
Once you are finished, you can proceed to the next step.
First, edit the MariaDB default configuration file and tweak some settings:
nano /etc/mysql/mariadb.conf.d/50-server.cnf
collation-server = utf8mb4_unicode_ci
max_heap_table_size = 128M
tmp_table_size = 64M
join_buffer_size = 1M
innodb_file_format = Barracuda
innodb_large_prefix = 1
innodb_buffer_pool_size = 512M
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
innodb_doublewrite = OFF
sort_buffer_size = 1M
Save and close the file then restart the MariaDB service to apply the changes:
mysql -u root -p
Once login, create a database and user for Cacti with the following command:
Next, flush the privileges and exit from the MariaDB shell with the following command:
Next, you will need to import timezone data to the MySQL database. You can import it with the
following command:
Next, log in to MariaDB shell and grant required privileges on MySQL timezone with the
following command:
mysql -u root -p
Next, flush the privileges and exit from the MariaDB shell with the following command:
Once you are finished, you can proceed to the next step.
Install and Configure Cacti
First, you will need to download the latest version of Cacti from its official website. You can
download it with the following command:
wget https://www.cacti.net/downloads/cacti-latest.tar.gz
Once the download is completed, extract the downloaded file with the following command:
Next, move the extracted directory to the Apache root directory with the following command:
mv cacti-1* /var/www/html/cacti
Next, import the database to the cactidb with the following command:
Next, edit the Cacti config.php file and define your database settings:
nano /var/www/html/cacti/include/config.php
verifying cacti database name ,username and password in the following lines:
$database_type = 'mysql';
$database_default = 'cacti';
$database_hostname = 'localhost';
$database_username = 'cactiuser';
$database_password = 'cactiuser';
$database_port = '3306';
Save and close the file then create a log file for Cacti.
touch /var/www/html/cacti/log/cacti.log
Next, set the full access/ownership and permission of the cacti directory with the following
command:
chown -R www-data:www-data /var/www/html/cacti/
Next, create a new Cacti cron job file with the following command:
nano /etc/cron.d/cacti
At this point, Cacti is installed and configured. You can now proceed to the next step.
nano /etc/apache2/sites-available/cacti.conf
<Directory /var/www/html/cacti>
Options +FollowSymLinks
AllowOverride None
</IfVersion>
Order Allow,Deny
</IfVersion>
AddType application/x-httpd-php .php
<IfModule mod_php.c>
php_flag short_open_tag On
php_flag register_argc_argv On
php_flag track_vars On
php_value mbstring.func_overload 0
php_value include_path .
</IfModule>
DirectoryIndex index.php
</Directory>
Save and close the file then enable the virtual host file with the following command:
a2ensite cacti
Once you are finished, you can proceed to the next step.
nano /etc/apache2/sites-available/000-default.conf
And paste in the end of the file you may check sample configuration
<Location "/server-status">
SetHandler server-status
</Location>
_________________SAMPLE_____________________
<VirtualHost *:56000>
# The ServerName directive sets the request scheme, hostname and port that
# match this virtual host. For the default virtual host (this file) this
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# modules, e.g.
ErrorLog ${APACHE_LOG_DIR}/error.log
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
#Include conf-available/serve-cgi-bin.conf
<Location "/server-status">
SetHandler server-status
</Location>
</VirtualHost>