# [How-to]: Installing cacti on a gentoo box (fresh install)

## Prompty

Formerly known as Unreliable guide to gentoo and cacti (install)

Ok, I'm writing this because I had a few problems before managing to finally get this running and had no luck finding a solution on the internet.

The use-flags I needed

```

gd dba mysql php svg apache2 zlib session

```

AND I think 

```
cli
```

I added session because there were problems with session support . ( now some of those flags you don't want to use on your system.)

OK now do a

```

emerge cacti

```

(preferably on a screen or some remote console)

--------Note------

you might need to re-emerge your php and mod_php for cacti to work

-------End-Note----

add a group cacti and user cactiuser ( cactiuser is suppoused to be in 

cacacti group ) something like

```

group-add cacti

useradd -g cacti cactiuser

```

Wait for the installation process to finish..

All that you need is in ( my case - fresh apache install )

```

cd /var/www/localhost/htdocs/cacti/

```

```

mysql --user=root cactidb < cacti.sql

chown -R cactiuser rra/ log/

```

in 

/var/www/localhost/htdocs/cacti/include/

you might want to do this with your mysql

Run these commands as root

```

mysql

mysql> set password for root@localhost=password('rootpw');

mysql> create database cactidb;

mysql> grant all on cactidb.* to root;

mysql> grant all on cactidb.* to root@localhost;

mysql> grant all on cactidb.* to cactiuser;

mysql> grant all on cactidb.* to cactiuser@localhost;

mysql> set password for cactiuser@localhost=password('mycactipw');

mysql> exit

```

```

cp config-sample.php config.php

vi config.php

```

the interesting part of config.php looks like this

```

$database_type = "mysql";

$database_default = "cactidb";

$database_hostname = "localhost";

$database_username = "cactiuser";

$database_password = "mycactipw";

```

Now in /etc/conf.d/apache2 i added

```

APACHE2_OPTS="-D PHP5"

```

Now start your apache 

/etc/init.d/apache2 start 

it should bring up mysql

now as user cactiuser

```
 su - cactiuser 
```

add this to your crontab 

```
crontab -e
```

```

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

```

you might want to try running this from you cactiuser shell.

REMEBER (i had some problems with that too ;] )  each cacti reinstall ruins  permissions to directories , do a

```

chown -R cactiuser.cacti rra/ log/

```

every once in a while

If you're wondering why you're getting a directory listing in your host_name_or_ip/cacti: remeber to to add index.php to your DirectoryIndex  in 

```
 vi /etc/apache2/httpd.conf
```

My case it looks like that

 *Quote:*   

> DirectoryIndex index.html index.html.var index.php

 

If you're having problems with graphs not showing still (reported on hardened gentoo):

-some people reported problems with php safe_mode ( I don't know what or where that is for the time being but ) you should turn it off

----------

## HRH_H_Crab

nice guide, big up yourself!

followed this and now my cacti is working lovely.

----------

## veal

[e] never mind, i should've read the official documentation where the default password is written  :Smile:  

i followed the guide that's printed after a successfull emerge (but looks similar to this one) and everything went smooth except after working through the website-config it prompts for a user/login 

"Please enter your Cacti user name and password below:"

but i never created a Cacti user and i tried several combos (of the mysql user etc.) but none of them worked.

any idea?

----------

## Prompty

if i remeber correctly it's "admin/admin"

----------

## JustJoe

Hi, i tried to install cacti, but it comes with this error:

```
dev-php/mod_php must be compiled with USE=mysql
```

Prolly n00b-ish, but how to fix this ?

edit: 

i put this in /etc/portage/package.use : 

```
dev-php/mod_php mysql
```

but it doesn't seem to be right.

*Solved:  I did not emerge dev-php/mod_php, only php....   :Confused:  

----------

## ruben-

Add this to the gentoo-wiki.. It looks good, but not working for me tho  :Sad: 

I don't get graphs, only unreadable images.

----------

## Suicidal

Thanks for the session use flag that fixed the problem I was having with php5; one question though shouldnt cli be added to the use flags if using php5? I tried it without it earlier today and there was no /usr/bin/php binary which would be needed to run the cron job.

----------

## overcast

What is the reason for creating a separate user for something like this?  Why not run as root?  Just good security practice and a healthy dose of paranoia or are there specific issues someone can site with running this as root?

Just curious.

----------

## raven.sorrow

this guide is great .... but Cacti uses SNMP (Simple Network Managment Protocol) There are very poor HOWTO's on how to set snmp up on a Gentoo Box. Can anyone shead any light on this subject?

----------

## wan-geek

You are correct that Cacti uses snmp.  It does -not- require snmp to be a running daemon on the local system however.

The function of snmp in Cacti is as a polling mechanism to remote systems.  You don't need to setup anything for snmp on the Cacti system to be able to use Cacti.  

When you emerge net-snmp, you will end up with a number of utilities that are a part of the package.  These can be used to query (and set) snmp values on remote systems.  If you have a system running an snmp daemon, you should be able to walk it's MIB tree via the command snmpwalk.

To brush up on snmp itself and it's use, I would check online.  There are numbers of great resources that explain the protocol in detail...it's usage and pitfalls.  To setup the snmp daemon to run on a system...I would refer to the man page for snmpd and snmpd.conf.  (hint: there's a wizard that you can run to build the configs for you...but the man page tells you that already:wink: )

In short, if you are trying to setup a machine to run cacti on...and act as a snmp _poller_ to remote systems, you don't need to do anything more with snmp than emerge it.

Cheers,

-Chris

----------

## wan-geek

In regards to overcast's question, ...regarding running as root...

Best practice states that the root user should be used as little as possible and only when specifically necessary.  Since Cacti has -0- need to run as root...it is most commonly setup to run as a separate user. 

If you want to run it as root, nobody is stopping ya.  Just remember that you chose to run it as root if/when anything goes awry and takes down the system.  

Cheers,

-Chris

----------

