Monday, July 26, 2010

Instal Cacti on OpenBSD


This is the step for installing cacti on openbsd.
I`m use OpenBSD 4.7 on VMWare Workstation 7 in Windows Desktop.


1. instal the package
Set the package PATH
#export PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/4.7/packages/i386/


   Package needed for OpenBSD :


  • rrdtool
  • apache-httpd
  • net-snmp
  • mysql-server
  • php5-core
  • php5-mysql
  • php5-snmp
Instal following package (ports) needed for OpenBSD
#pkg_add rrdtool net-snmp php5-core php5-snmp apache-httpd

Instal MYSQL-SERVER
# pkg_add mysql-server

Create the Default Database
# /usr/local/bin/mysql_install_db
Start the database server
# /usr/local/bin/mysqld_safe >/dev/null 2>&1 &
Set the passwords
#/usr/local/bin/mysqladmin -u root password 'new-password'
You should replace "new-password" with an actual one.

Instal PHP
# pkg_add php5-mysql

This will automatically backtrack and install PHP5 itself.

Then ...

# ln -s /var/www/conf/modules.sample/php5.conf /var/www/conf/modules

# ln -fs /var/www/conf/php5.sample/mysql.ini /var/www/conf/php5/mysql.ini

Then you have to modify /var/www/htdocs/httpd.conf
to include php files as usable index files Apache.
In /var/www/conf/httpd.conf, enter, find where it says:

DirectoryIndex index.html

And change it to

DirectoryIndex index.html index.php

and uncomment the following line:

AddType application/x-httpd-php .php

Instal PHPMYADMIN
# pkg_add -v phpMyAdmin

The the soft links-
# ln -fs /var/www/conf/php5.sample/gd.ini /var/www/conf/php5/gd.ini

# ln -fs /var/www/conf/php5.sample/mbstring.ini /var/www/conf/php5/mbstring.ini

# ln -fs /var/www/conf/php5.sample/mcrypt.ini /var/www/conf/php5/mcrypt.ini

# ln -fs /var/www/conf/php5.sample/mysql.ini /var/www/conf/php5/mysql.ini

# ln -s /var/www/phpMyAdmin/ /var/www/htdocs/phpmyadmin

Edit the /var/www/phpMyAdmin/config.inc.php file
so that the blowfish secret is set to whatever you want,
and the username and password for the server are set
to whatever you configured for access in the MySQL installation.
This will also act as the authentication into phpMyAdmin as well.
Then restart Apache.

2. Starting the apache

# apachectl start

if you want to verify that php is actually working after getting apache running:

Open http://yourserver ip/ in your favorite web browser.

3. Install cacti
download cacti from http://cactiusers.org/downloads/

# cd /var/www
# ftp -a http://www.cacti.net/downloads/cacti-0.8.7g.tar.gz
# tar -xzvf cacti-0.8.7g.tar.gz

Add a couple useful links for the inevitable, if infrequent, update:

# cd /var/www
# ln -s cacti-0.8.7g cacti
# cd /var/www/htdocs
# ln -s ../cacti cacti

4. Database Setup
Create the database and setup MySQL authentication.

# cd cacti-0.8.7g
# mysql -u root -p 
mysql>create database cacti;
mysql>exit
# mysql -u root -p cacti < cacti.sql
# mysql -u root -p cacti
mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'somepassword';
mysql> flush privileges;

if failed to load cacti.sql to cacti database,
open http://yourserver-ip/phpmyadmin/

create database named "cacti" , then
back to OpenBSD root command

# mysql -u root -p cacti < cacti.sql
# mysql -u root -p cacti
mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'somepassword';
mysql> flush privileges;

Edit 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 = "somepassword";

5. System User
Create a system user to run the cron jobs and own the rra and log files,
then set the appropriate permissions on cacti's directories for graph/log generation.

# useradd -u900 -g=uid -c "Cacti user" -d /var/empty -s /sbin/nologin _cacti
# chown -R _cacti rra/ log/

Add a line to your /etc/crontab file similar to:

*/5 * * * * _cacti /usr/local/bin/php /var/www/cacti/poller.php > /dev/null 2>&1

add following line in /etc/rc.conf.local
httpd_flags="-u"


6. Jump into cacti

Point your web browser to: http://yourserver-ip/cacti/. Follow the prompts from there.

2 comments:

  1. what this comment
    # ln -fs /var/www/conf/php5.sample/mysql.ini /var/www/conf/php5/mysql.ini ?

    I can't enter that script on the my OBSD

    please explain

    ReplyDelete
  2. what this comment
    # ln -fs /var/www/conf/php5.sample/mysql.ini /var/www/conf/php5/mysql.ini ?

    I can't enter that script on the my OBSD

    please explain

    ReplyDelete