Thursday, April 15, 2010

Building Cacti on Ubuntu Server 8.04 Hardy Heron

Although it seems difficult, after several trial and error on my Ubuntu Server 8.04 finally I can get my Cacti up and running :) I copy-paste from Cacti website installation document and editing several lines to suite Ubuntu. First of all, you need to install from repositories (including all dependencies):
- apache2
- php5
- php5-cli
- rrdtool
- snmp
- cacti sourse file from here, choose the latest version

Configure PHP
Please find the file /etc/php5/apache2/php.ini and make the following changes to it:
extension_dir = /etc/php.d
This will enable PHP to find more configuration directives in that very directory.

If you want to allow template importing, uncomment the following line:

file_uploads = On
 Activate the MySQL extension via /etc/php5/conf.d/mysql.ini
; Enable mysql extension module
Activate the SNMP extension via /etc/php5/conf.d/mysql.ini
; Enable snmp extension module

Configure the Webserver (Apache)
Please locate the PHP configuration file at /etc/apache2/httpd.conf
If using PHP 5, then add the following lines.
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
LoadModule php5_module modules/
# Cause the PHP interpreter to handle files with a .php extension.
AddHandler php5-script .php
AddType text/html .php
# Add index.php to the list of files that will be served as directory
# indexes.
DirectoryIndex index.php
Configure MySQL
Set a password for the root user
# mysqladmin --user=root password somepassword
# mysqladmin --user=root --password reload

Install and Configure Cacti
1. Extract the distribution tarball
# tar xzvf cacti-version.tar.gz

2. Create the MySQL database:
# mysqladmin --user=root create cacti

3. Import the default cacti database:

# mysql cacti < /path/to/cacti/cacti.sql

4. Optional: Create a MySQL username and password for Cacti.
# mysql --user=root mysql
mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'somepassword';
mysql> flush privileges;

Edit /path/to/cacti/include/config.php and specify the database type, name, host, user and password for your Cacti configuration.
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cacti";

Set the appropriate permissions on cacti's directories for graph/log generation. You should execute these commands from inside cacti's directory to change the permissions.
# chown -R cactiuser rra/ log/

(Enter a valid username for cactiuser, this user will also be used in the next step for data gathering)

Point your web browser to:


Log in the with a username/password of admin
. You will be required to change this password immediately. Make sure to fill in all of the path variables carefully and correctly on the following screen.

For Ubuntu Distro, I have found that crontab setting is a bit different. You must edit /etc/cron.d/cacti files in order the cron to be running (Usually we used crontab -e in any linux/unix to add cron job)

$ cat /etc/cron.d/cacti
*/5 * * * * root php /var/www/cacti/poller.php > /dev/null 2>&1 /var/log/cacti/poller-error.log

No comments:

Post a Comment

Hi, for all of those who already put comments on my blog post, thanks.. really appreciate it. And for those who have not, just put your comments here :)