0% found this document useful (0 votes)
73 views9 pages

How to configure and install cacti on Ubuntu_linux

Uploaded by

Faiz Firmansyah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views9 pages

How to configure and install cacti on Ubuntu_linux

Uploaded by

Faiz Firmansyah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

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.

Install LAMP Server


Next, you will need to install the Apache web server, MariaDB, PHP and other required PHP
extensions to your server. You can install all of them by running the following command:

apt-get install apache2 mariadb-server php php-mysql libapache2-mod-php php-


xml php-ldap php-mbstring php-gd php-gmp php-intl -y

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:

systemctl restart apache2

Once you are finished, you can proceed to the next step.

Configure MariaDB Server


Cacti uses MariaDB as a database backend. So you will need to create a database and user for
Cacti.

First, edit the MariaDB default configuration file and tweak some settings:

nano /etc/mysql/mariadb.conf.d/50-server.cnf

Add / Modify the following lines inside [mysqld] section:

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:

systemctl restart mariadb

Next, log in to the MariaDB shell with the following command:

mysql -u root -p

Once login, create a database and user for Cacti with the following command:

MariaDB [(none)]> create database cacti;

MariaDB [(none)]> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY


'cactiuser';

Next, flush the privileges and exit from the MariaDB shell with the following command:

MariaDB [(none)]> flush privileges;

MariaDB [(none)]> exit;

Next, you will need to import timezone data to the MySQL database. You can import it with the
following command:

mysql mysql < /usr/share/mysql/mysql_test_data_timezone.sql

Next, log in to MariaDB shell and grant required privileges on MySQL timezone with the
following command:

mysql -u root -p

MariaDB [(none)]> GRANT SELECT ON mysql.time_zone_name TO cactiuser@localhost;

Next, flush the privileges and exit from the MariaDB shell with the following command:

MariaDB [(none)]> flush privileges;

MariaDB [(none)]> exit;

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:

tar -zxvf cacti-latest.tar.gz

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:

mysql cacti < /var/www/html/cacti/cacti.sql

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';

It’s a default parameters

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/

chmod -R 775 /var/www/html/cacti/

Next, create a new Cacti cron job file with the following command:

nano /etc/cron.d/cacti

Add the following line:

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

Save and close the file when you are finished.

At this point, Cacti is installed and configured. You can now proceed to the next step.

Configure Apache for Cacti


Next, you will need to create an Apache virtual host configuration file for Cacti. You can create
it with the following command:

nano /etc/apache2/sites-available/cacti.conf

Add the following lines:

Alias /cacti /var/www/html/cacti

<Directory /var/www/html/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>

Save and close the file then enable the virtual host file with the following command:

a2ensite cacti

Next, restart the Apache service to apply the configuration changes:

systemctl restart apache2

Once you are finished, you can proceed to the next step.

Access Cacti Web Interface


http://127.0.0.1/cacti
default username and password
admin/admin
You may add Cacti setting under Apache Directory yo change IPv4 instead localhost

Edit below file

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

Require host 192.168.88.86

</Location>

_________________SAMPLE_____________________

<VirtualHost *:56000>

# The ServerName directive sets the request scheme, hostname and port that

# the server uses to identify itself. This is used when creating

# redirection URLs. In the context of virtual hosts, the ServerName

# specifies what hostname must appear in the request's Host: header to

# match this virtual host. For the default virtual host (this file) this

# value is not decisive as it is used as a last resort host regardless.

# However, you must set it for any further virtual host explicitly.

#ServerName www.example.com

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,

# error, crit, alert, emerg.

# It is also possible to configure the loglevel for particular

# modules, e.g.

#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log

CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are

# enabled or disabled at a global level, it is possible to

# include a line for only one particular virtual host. For example the

# following line enables the CGI configuration for this host only

# after it has been globally disabled with "a2disconf".

#Include conf-available/serve-cgi-bin.conf

<Location "/server-status">

SetHandler server-status

Require host 192.168.88.86

</Location>

</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

You might also like