Install Cacti from source on Ubuntu/Debian Server

Install Cacti Pre-Requisite Requirement

#sudo apt-get update

Installing Apache, PHP, PHP extension, SNMP :
sudo apt-get install apache2 php5 php5-mysql php5-snmp snmp snmpd php5-gd
Installing RRD-Tool :
sudo apt-get install rrdtool
sudo apt-get install mysql-server
Create system user for cacti
Create one system user for cacti. Later in this post you will know where we will use it
sudo useradd cactiuser
Workaround in MySQL database server
First login into mysql server, use the mysql root password which you have set while installing mysql server.
mysql -u root -p
mysql> create database cactidb;
mysql> CREATE USER 'cactiuser'@'localhost' IDENTIFIED BY 'Password';
mysql> GRANT ALL ON cactidb.* TO 'cactiuser'@'localhost'; 
mysql> flush privileges;
mysql> exit
Download and extract the Cacti tar ball. We will copy the extracted out cacti source and rename as cacti in /var/www/html directory.
wget http://www.cacti.net/downloads/cacti-0.8.8d.tar.gz

tar -xvzf cacti-0.8.8d.tar.gz

sudo cp -prvf cacti-0.8.8d /var/www/html/cacti
Restore cacti database from dump file
Use the already available cacti.sql dump file to restore into Cacti database.
mysql -u root -p cactidb < /var/www/html/cacti/cacti.sql
Settings for Cacti in config.php
sudo vi /var/www/html/cacti/include/config.php
Do the follow settings in config.php and set the correct values.
$database_type = "mysql";
$database_default = "cactidb";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "Password";
$database_port = "3306";
$database_ssl = false;

$url_path = "/cacti/";

$cacti_session_name = "Cacti";
Change the Ownership and group of cacti web directory to apache user that is www-data .
chown -R www-data:www-data /var/www/html/cacti/
Change ownership of rra and log directory in cacti web directory with cactiuser (it is system user which we created in beginning of this post).
chown -R cactiuser /var/www/html/cacti/rra/ /var/www/html/cacti/log/
Set crontab for poller script
vi /etc/crontab
Add the following given line at end of crontab. The cron will be run by user cactiuser in every 5 minutes,daily
## Cacti
*/5 * * * * cactiuser php /var/www/html/cacti/poller.php > /dev/null 2>&1
sudo service apache2 restart
Follow the installation in Web browser interface

Now rest of installation process will be completed through web browser interface.
Open the web browser and type the IP address of cacti server suffix by /cacti .

For eg. our cacti server ip address is 192.168.122.116 , hence in web browser we will typehttp://192.168.122.116/cacti....................................
In next screen, you will get login form on screen.
By default username/password is admin/admin . Use the username and password in login form
Some graphs of localhost. (Just wait for 5 minutes, you will see the graphs)

Check Cacti log:
#tailf /var/www/html/cacti/log/cacti.log
Check cron log and all log
#tailf /var/log/syslog
Rebuild Poller Cache
Whenever the Poller Interval is changed, the cache must be emptied. To do this, click “System Utilities” under the Utilities heading on the left-hand navigation panel.Click on “Rebuild Poller Cache” to empty the cache.