How to Install Cacti on Ubuntu 16.04

Requirements

Launch Alibaba Cloud ECS Instance

apt-get update -y

Install Apache, MariaDB and PHP

apt-get install -y apache2 mariadb-server mariadb-client php-mysql libapache2-mod-php7.0 -y
apt-get install php7.0-xml php7.0-ldap php7.0-mbstring php7.0-gd php7.0-gmp snmp php7.0-snmp rrdtool librrds-perl -y

Configure Database

mysql_secure_installation
Enter current password for root (enter for none):
Set root password? [Y/n]: N
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y
mysql -u root -p
MariaDB [(none)]> create database cactidb;
MariaDB [(none)]> GRANT ALL ON cactidb.* TO cactiuser@localhost IDENTIFIED BY 'password';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit;
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 = 64M
innodb_buffer_pool_size = 512M
innodb_doublewrite = off
innodb_additional_mem_pool_size=96M
innodb_flush_log_at_timeout = 3
innodb_read_io_threads = 32
innodb_write_io_threads = 16
nano /etc/php/7.0/apache2/php.ini
date.timezone = Asia/Kolkata
systemctl restart apache2
systemctl restart mysql

Download and Install Cacti

wget https://www.cacti.net/downloads/cacti-latest.tar.gz
tar -xvzf cacti-latest.tar.gz
cp -r cacti-1.1.38 /var/www/html/cacti
touch /var/www/html/cacti/log/cacti.log
chown -R www-data:www-data /var/www/html/cacti
chmod -R 777 /var/www/html/cacti
cd /var/www/html/cacti
mysql -u root -p cactidb < /opt/cacti/cacti.sql
nano include/config.php
$database_type = "mysql";
$database_default = "cactidb";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "password";
$database_port = "3306";
$database_ssl = false;

Configure Apache for Cacti

nano /etc/apache2/sites-available/cacti.conf
<VirtualHost *:80>
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>
</VirtualHost>
a2ensite cacti
systemctl restart apache2
nano /etc/crontab
*/5 * * * * www-data php /var/www/html/cacti/poller.php > /dev/null 2>&1
systemctl restart cron

Access Cacti Web Installation Wizard

Original Source

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store