How To Install Cacti on CentOS 6

install cacti on centos

Cacti is an open-source, web-based network monitoring and graphing tool designed as a front-end application for the open-source, industry-standard data logging tool RRDtool. It is used by IT businesses and stores all of the necessary information about bandwidth, hard disk usage, CPU usage, load average, RAM statistics etc in a MySQL database. Cacti creates graphs and populates them with data. It offers SNMP support, 3rd party templates and plugins and has built in user authentications and user permission features.

This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple. I will show you through the step by step installation Cacti on CentOS 6.

Step 1. First, you need to enable EPEL repository on your system.

## RHEL/CentOS 6 64-Bit ##
# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm
## RHEL/CentOS 6 32-Bit ##
# wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm

Step 2. Install required packages.

Install apache:

 yum install httpd httpd-devel

Install MySQL server:

 yum install mysql mysql-server

Intsall PHP modules:

 yum install php-mysql php-pear php-common php-gd php-devel php php-mbstring php-cli php-mysql

Install PHP-SNMP:

 yum install php-snmp

Install NET-SNMP:

 yum install net-snmp-utils p net-snmp-libs

Install RRDTool:

 yum install rrdtool

Once installed all the above softwares, start them:

/etc/init.d/mysqld start
/etc/init.d/httpd start
/etc/init.d/snmpd start

In order for these services to run at startup we need to enter the following commands:

chkconfig mysqld on
chkconfig httpd on
chkconfig snmpd on

Step 2. Install Cacti.

chkconfig mysqld on
chkconfig httpd on
chkconfig snmpd on

Step 3. Configuring MySQL.

By default, MySQL is not hardened. You can secure MySQL using the mysql_secure_installation script. you should read and below each steps carefully which will set root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MySQL.

 mysql_secure_installation

Cacti requires a MySQL user and database, so create them by executing the following commands:

# mysql -u root -p
create database cacti;
grant all privileges on cacti.* to 'cactiuser'@'localhost' identified by 'your-password-here';
flush privileges;
exit

Step 4. Setup Cacti tables to MySQL.

Now import cacti database tables from the file cacti.sql . Issue the below command to find the location of cacti.sql file:

#rpm -ql cacti | grep cacti.sql
/usr/share/doc/cacti-0.8.8a/cacti.sql

Now we need to install the tables into the cacti.sql file. Use the following command to do this and enter your database password when prompted:

 #rpm -ql cacti | grep cacti.sql
/usr/share/doc/cacti-0.8.8a/cacti.sql

Now we need to edit the database configuration file of cacti so that it uses the correct database name and username:

 mysql -u cactiuser -p cacti < /usr/share/doc/cacti-0.8.8b/cacti.sql

Configure MySQL settings for Cacti. Open /etc/cacti/db.php with your favourite editor and enter the values for your ‘cacti’ database:

 nano /etc/cacti/db.php
/* 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 = "your-password-here";
$database_port = "3306";
$database_ssl = false;

Step 5. Configure the Apache Server.

We can change the Apache configuration to choose what IP addresses / subnets are allowed to connect. You can do this by editing the following file:

##nano /etc/httpd/conf.d/cacti.conf

<Directory /usr/share/cacti/>
 Order Deny,Allow
 Deny from none
 Allow from <YOUR_IP_ADDRESS_RANGE>
 </Directory>

Restart Apache:

 /etc/init.d/httpd restart

Step 6. Configure Cron for Cacti.

Open /etc/cron.d/cacti file:

nano /etc/cron.d/cacti
###Remove the # in the following line###
#*/5 * * * * cacti /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1

Step 7. Configuring Iptables or firewall for Cacti.

iptables -A INPUT -p udp -m state --state NEW --dport 80 -j ACCEPT
iptables -A INPUT -p tcp -m state --state NEW --dport 80 -j ACCEPT
service iptables save

Step 8. Accessing Cacti.

Cacti will be available on HTTP port 80 by default. Open your favorite browser and navigate to http://yourdomain.com/cacti or http://server-ip/cacti. The default username and password for Cacti is admin / admin. Upon first login, you will be force to change the default password.

Congratulation’s! You have successfully installed Cacti.

How To Install Webmin on CentOS

In this tutorial we will learn How To Install Webmin on CentOS, lets go-

Webmin is a free control Panel for managing VPS. Webmin is a web based interface which is used to manage VPS web hosting server. With the help of webmin you can setup user account, apache, dns & file sharing and other actions. Webmin very suitable for beginners who do not know much about the unix or linux command line. For future reference, I will show you a steps to setup on Webmin 1.720 on CentOS.

Install Webmin on CentOS

Step 1. First setup webmin using Yum

#nano /etc/yum.repos.d/webmin.repo

[Webmin]
name=Webmin Distribution Neutral
#baseurl=http://download.webmin.com/download/yum
mirrorlist=http://download.webmin.com/download/yum/mirrorlist
enabled=1

We’ll need to install webmin GPG key now, using following command.

 rpm --import http://www.webmin.com/jcameron-key.asc

Now, update the repositorys:

 yum check-update

Step 2. Install webmin using rpm command.

 yum install webmin -y

Step 3. Start Webmin.

 /etc/init.d/webmin start

Now execute following commands to make sure that Webmin starts automatically every time you reboot your server:

 chkconfig webmin on

Once Webmin has finished installing you should be load the following address in your browser. http://youripaddress:10000

install webmin in centos

Congratulation’s! You have successfully installed Webmin. Thanks for using this tutorial for installing Webmin free web hosting control panel  on CentOS system. For additional help or useful information, we recommend you to check the official Webmin web site.