Installing Cacti on CentOS with yum
I’ve been wanting to try the Cacti network graphing system for a while, but wasn’t sure how much effort it would take. Well, it wasn’t too bad, and here are the steps that I used. Hopefully this will save someone else a few minutes.I started with the CentOS 4.3 Server CD. I really like having a single CD that will install what’s necessary for a server. I use the .iso and VMWare Server, and can have a server installed from scratch in very little time. For this server, I chose to customize the list of packages. I unchecked Mail Server, Windows File Server, DNS Name Server, FTP Server, and Printing Support. I added System Tools. I’ll assume that you have your OS installed at this point.
Configure yum. Since I want to use yum as much as possible, and cacti is not in the default CentOS repositories, I added Dag to my list of repositories. This is as simple as creating the file /etc/yum.repos.d/Dag.repo and putting the following in it:
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=0
enabled=1
protect=0
That last option (“protect=0″) only does anything if you’ve installed the ProtectBase plugin for yum. This plugin keeps yum from updating system or base packages from non-CentOS repositories (or however you want to configure it). You can read about it here.
Install prerequisites. Now we need to install the packages that Cacti depends on, and the Cacti package itself. Use yum, and allow it to install any dependencies for the following packages. Just running “yum install cacti” might have caught all of these too, but I didn’t try that.
shell# yum install net-snmp
shell# yum install mysql
shell# yum install mysql-server
shell# yum install cacti
Configure Apache. By default, the cacti.conf file in /etc/httpd/conf.d is set to deny access to everyone. I made a copy of the file for safekeeping and then edited cacti.conf to remove the line “deny from all”.
Start services. Now we need to start some services and set them to start whenever the machine starts up:
shell# service mysqld start
shell# service httpd start
shell# chkconfig –level 345 mysqld on
shell# chkconfig –level 345 httpd on
Configure mysql. Now your server is actually serving up Cacti documentation from http://servername/cacti/docs/html/index.html. These last steps are from the Installing under Unix page at http://servername/cacti/docs/html/install_unix.html.
shell# mysqladmin –user=root create cacti
shell# cd /var/www/cacti
shell# mysql cacti < cacti.sql
shell# mysql --user=root mysql
mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY ‘cactiuser’;
mysql> flush privileges;
mysql> exit
shell#
Schedule the poller. Add a line like the following to /etc/crontab to schedule the poller:
*/5 * * * * cacti php /var/www/cacti/poller.php > /dev/null 2>&1
Complete the installation. Browse to http://servername/cacti/index.php and follow the instructions to complete the installation. You should just need to click Next>, Next>, Finish.
Login and begin to use Cacti. Login as admin, password admin, and change the password as required. Now you’re ready to start using Cacti! After I gain some experience, I may post some tips.








Comment by Bennett Haselton on 9 November 2007:
Great instructions, thanks!
One thing: in the line where you wrote:
chkconfig -level 345 mysqld on
your blogging software evidently converted the regular ASCII “-” character into a high-order ASCII character 0×96, a “high-order ASCII dash”. This meant when I tried copying and pasting the command into my console window, it didn’t work. I don’t know if there’s a way to force the blogging software to publish it as a regular dash.
Comment by Bennett Haselton on 9 November 2007:
Actually, I should have written:
chkconfig –level 345 mysqld on
That’s two regular ASCII dashes, not one, before the word “level”. Unfortunately a lot of word-processing systems will auto-convert this into the 0×96 character, which is probably what your blogging software did. It might do that when I post this comment too.
Comment by Bennett Haselton on 9 November 2007:
Same thing happens with another command in the instructions:
GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY ‘cactiuser’;
Those should be regular single quotes around the words “cactiuser”, but your blog apparently converted them into those fancy curly-quotes (the same thing that Microsoft Word does).
Comment by sepand on 3 January 2008:
i run */5 * * * * cacti php /var/www/cacti/poller.php > /dev/null 2>&1
insted place it in cron fild and cacti stop showing updated graph what should i do. thanks
Comment by karl.kranich on 29 January 2008:
The only thing that I can suggest is that sometimes in the crontab you need to specify the full path to executables. Figure out where php resides and put in the full path instead of just “php”.
Comment by sepand on 20 February 2008:
i understand that CentOS by self add the crontab and does not necessary to manually do the cron. if you do it just mess the system and it stop working.
Comment by mustu on 16 June 2008:
hey! i did as written above. everything went fine but the index.php isn’t opening. i didn’t get any permission or any kind of error but just a blank page.. can u help me whats goign wrong?
Comment by me on 4 September 2008:
mutsu I get the same thing, did you figure yours out?
Comment by me on 4 September 2008:
ok, finally figured it out:
/etc/php.ini
extension_dir = “/usr/lib/php/modules”
Comment by putra koreng on 1 January 2009:
seeeeeeeeeeeeeeeeeep..Thanks
http://putra-koreng.blogspot.com/2008/12/router-centos.html
Comment by Jason Gegere on 6 November 2009:
Works great. Few syntax errors but overall nice job.
Pingback by Cacti Install on RHEL 5 or CentOS 5 « W dream on 22 January 2010:
[...] Installing Cacti on CentOS with yum Share and Enjoy: [...]
Pingback by Installing Cacti on CentOS Linux 5.4 « Aaron Walrath – Another IT guy on 28 February 2010:
[...] http://blogs.kranich.org/karl/2006/09/14/installing-cacti-on-centos-with-yum/ Possibly related posts: (automatically generated)Cacti installation with plugins in centos/fedora/rhelInstalling Cacti on CentOS [...]
Comment by platinumpresto on 14 February 2011:
worx 4 m3