Install Cacti on CentOS 5
From CSLabsWiki
This page summarizes how to perform a basic installation of Cacti on CentOS 5. This tutorial assumes you have root/sudo access and have SELinux set to permissive or disabled.
If you notice a problem with this How-To or would like to provide feedback, please email Matt.
Contents
Install
Add RPMForge Yum Repository
![]() |
It is recommended that you configure yum-priorities prior to following this tutorial to avoid having base CentOS packages being overwritten by the RPMForge repository. Instructions to do so can be found on the CentOS Wiki. |
- For x86 (32-bit) systems
- For x64 (64-bit) systems
Install & Configure Prerequisites
- Install Apache
yum install httpd
- Configure Apache to start on boot
/sbin/chkconfig --levels 345 httpd on
- Configure iptables to allow Apache traffic
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
/etc/init.d/iptables save
/etc/init.d/iptables restart
Install & Configure Cacti and MySQL
- Install Cacti & Required Dependencies
yum install cacti mysql-server mysql php-mysql net-snmp net-snmp-utils php-snmp liberation-fonts
- Configure
mysqld
to start on boot/sbin/chkconfig --levels 345 mysqld on
- Start
mysqld
/etc/init.d/mysqld start
- Set the password for the MySQL root user
/usr/bin/mysqladmin -u root password 'PASSWORD-GOES-HERE'
- Create the MySQL cacti database (Note: The password you will be prompted for is the one you just set.)
/usr/bin/mysqladmin -u root -p create cacti
- Log into the MySQL database and grant the
cactiuser
access to the cacti database/usr/bin/mysql -u root -p
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 46
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> GRANT ALL ON cacti.* TO 'cactiuser'@'localhost' IDENTIFIED BY 'CACTIUSER-PASSWORD-GOES-HERE';
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
- Populate the cacti database (Note: You will use the password you created for
cactiuser
here)/usr/bin/mysql cacti -u cactiuser -p < /var/www/cacti/cacti.sql
- Modify
/var/www/cacti/include/config.php
to have the correct password for the cacti database
$database_password = "CACTIUSER-PASSWORD-GOES-HERE";
- Modify root's crontab to update Cacti every five minutes
crontab -e
# Used to update Cacti
*/5 * * * * /usr/bin/php /var/www/cacti/poller.php >> /var/log/cacti 2>&1
- Modified
/etc/httpd/conf.d/cacti.conf
to fix url and allow access from anywhere
Alias /cacti /var/www/cacti/
<Directory /var/www/cacti/>
DirectoryIndex index.php
Options -Indexes
AllowOverride all
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc on
php_flag track_vars on
</Directory>
- Start Apache
/etc/init.d/httpd start
- Go to
http://servername/cacti/
& go through the following screens
Verify Install
- Try logging into your new Cacti installation by going to
http://servername/cacti/
and logging in with the default user (admin
) and the default password (admin
).