In order to install and run Cacti, we need to make sure that all system prerequisites are met. Here we’ll give an overview of the different components needed.
As most of Cacti is built as a web interface, a web server is needed. This can be Apache’s httpd or Microsoft’s Internet Information Server (IIS) if installing on Windows, but in fact, any PHP-capable web server can be used to run the web interface. For optimal support, the use of Apache or IIS is suggested.
Cacti is built with the PHP programming language and therefore needs PHP to be installed on the system. Most Linux distributions already have a base PHP environment installed, but some might need additional packages for Cacti to function properly. In particular, the LDAP, SNMP, and MySQL extensions should be installed.
Cacti uses the freely available MySQL database engine as its database server and it is available on most operating systems. One should note that the database server does not need to be installed on the same host as Cacti. For best performance, MySQL version 5 should be used.
The NET-SNMP package provides the SNMP binaries used by Cacti and supports SNMPv1, SNMPv2c, and SNMPv3.
The NET-SNMP package also provides the SNMP daemon for Linux.
You’re now going to install Cacti from source on a CentOS 5 system. You should use at least Centos 5.5 as it is 100% binary compatible with RedHat Enterprise Linux 5, but in fact you can follow most of the installation processes on other Linux distributions, such as Ubuntu or SuSe Linux, as well. By installing from source you’ll get some insight into the inner workings of Cacti, and it will also provide you with a system which most Cacti and plugin developers are used to. There are differences between a source installation and a Yum/APT installation, but they will be described later on. Let’s get started.
Assume that the CentOS system has been installed with only the “Server Package” selected and there is no graphical user interface installed.
This is the default installation for a CentOS system with no manual package selection.
The default CentOS installation is missing several important packages. So, we are now going to install these.
rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
yum install mysql-server php-mysql net-snmp-utils rrdtool php-snmp
You just gave the system a location to find the remaining packages needed for the Cacti installation and then installed them; therefore, you are now ready to start the next installation phase.
Go to http://www.cacti.net and download the latest version of Cacti. In the top-left corner, under Latest Files, right-click on the tar.gz file and save the link address to the clipboard. You are going to need this link later. For simplicity we’re assuming that your server has an Internet connection.
It’s now time to download the latest version of Cacti to your server. You will need your system username and password to login to your CentOS installation. If you have installed your CentOS system with the default settings, you should already have an SSH server running. If you’re already logged on to the machine, you can ignore the first step.
wget http://www.cacti.net/downloads/cacti-0.8.7g.tar.gz
You should see the following output on your screen:
tar-xzvf cacti-0.8.7g.tar.gz
ln -s cacti-0.8.7g cacti
You downloaded the latest Cacti version to the root directory of the web server and created a symbolic link to the extracted directory. With the Cacti files in place, you are now ready for the next phase of the installation process.
The database isn’t automatically created during the installation of Cacti. Therefore, you need to create it here. At the same time, a database user for Cacti should be created to allow it to access the database. It’s also a good idea to secure the MySQL database server by using one of the included CentOS tools.
mysql -u root mysql
SET PASSWORD FOR root@localhost = PASSWORD('MyN3wpassw0rd');
DROP DATABASE test;
DELETE FROM user WHERE NOT (host = "localhost" AND user = "mydbadmin");
/usr/bin/mysql_secure_installation
mysqladmin -u root -p create cacti
This will ask for the MySQL root password which you provided in Setup Step 1. When finished, you will have an empty database called cacti.
mysql -p cacti < /var/www/html/cacti/cacti.sql
mysql -u root -p mysql
GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'MyV3ryStr0ngPassword'; flush privileges; exit
You used some tools to secure the MySQL server and created a database. You also filled the Cacti database with the initial data and created a MySQL user for Cacti. However, Cacti still needs to know how to access the database, so let’s move on to the next step.
In case you are not using CentOS to install Cacti, you can use some MySQL internal functions to secure your installation.
You need to tell Cacti where to find the database and which credentials it should use to access it. This is done by editing the config.php file in the include directory.
The database and some other special configuration tasks are done by editing the information in the config.php file.
cd /var/www/html/cacti/include
vi config.php
You changed the database configuration for Cacti to the username and password that you created earlier. These settings will tell Cacti where to find the database and what credentials it needs to use to connect to it. You also changed the default URL path to fit your installation. As you install Cacti to /var/www/html/cacti, a sub-directory of the document root, you need to change this setting to /cacti/, otherwise Cacti will not work correctly.
I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…
Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…
Once we learn how to deploy an Ubuntu server, how to manage users, and how…
Key-takeaways: Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…
While developing a web application, or setting dynamic pages and meta tags we need to deal with…
Software architecture is one of the most discussed topics in the software industry today, and…