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.


Add RPMForge Yum Repository

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
  • 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";
  • 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
  • Start Apache
    • /etc/init.d/httpd start




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).