Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Thu Aug 17, 2017 3:05 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: [HOWTO] CentOS 7 and 0.8.8f
PostPosted: Tue Oct 27, 2015 10:16 am 
Offline

Joined: Fri Sep 14, 2012 6:57 pm
Posts: 10
I prefer to keep things as vanilla and minimal as possible so I created a set of commands that takes a Minimal CentOS install and turns it into a Cacti 0.8.8f server. I realize you can add about 1000 lines to this to further customize your installation but this set of commands get me from bare OS to a cacti login by cutting and pasting them into a shell window and that's what my goal was.

Anything in red will likely need to be changed for your installation.

Start by doing a minimal install of CentOS 7. Once that is bootable you can continue with the commands below.

#Using vi or some other method change the /etc/sysconfig/network-scripts/ifcfg-ens160 to the below values that match your configuration
BOOTPROTO=static
IPADDR=192.168.1.85
NETMASK=255.255.255.0
NM_CONTROLLED=no
ONBOOT=yes
GATEWAY=192.168.1.2
DEVICE=ens160

#Using vi or some other method change the /etc/resolv.conf nameserver values to your local DNS server and domain
search yourdomain.com
nameserver 192.168.1.12
nameserver 8.8.8.8

#Install all the needed packages and update everything to the latest version
yum -y install wget perl nano httpd httpd-devel mariadb-server php-mysql php-pear php-common php-gd php-devel php php-mbstring php-cli php-snmp net-snmp-utils net-snmp-libs rrdtool tcpdump net-tools
yum -y update

#
#
#I use VMware so I also install the tools. VMware tools aren't technically necessary so you can skip this section but I advise it if you're running VMware
#In VMware's remote console select VM->Guest->Install/Upgrade VMware tools
#
#
#
mount /dev/cdrom /mnt
cd
tar xvf /mnt/VMwareTools*
cd vmware-tools-distrib
./vmware-install.pl --default
systemctl status vmware-tools.service

#start and set these servers to start on bootup
systemctl start httpd.service
systemctl start mariadb.service
systemctl start snmpd.service
systemctl enable httpd.service
systemctl enable mariadb.service
systemctl enable snmpd.service

#download and extract cacti 0.8.8f into /usr/share and rename it as cacti
cd /usr/share
curl http://www.cacti.net/downloads/cacti-0.8.8f.tar.gz | tar xvz
mv cacti-0.8.8f cacti

#create a script to automate creation of database
echo "create database cacti;" >> /tmp/script.sql
echo "GRANT ALL ON cacti.* TO [email protected] IDENTIFIED BY 'databasepassword';" >> /tmp/script.sql
echo "FLUSH privileges;" >> /tmp/script.sql

mysqladmin -u root password databasepassword
mysql -u root --password=databasepassword< /tmp/script.sql
mysql -u cacti --password=databasepassword cacti < /usr/share/cacti/cacti.sql

sed -i 's/$database_password = "cactiuser";/$database_password = "databasepassword";/' /usr/share/cacti/include/config.php
sed -i 's/$database_username = "cactiuser";/$database_username = "cacti";/' /usr/share/cacti/include/config.php

#add http access in the firewall config
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --reload

#fix selinux so apache can e-mail and connect via network
setsebool -P httpd_can_sendmail=1
setsebool -P httpd_can_network_connect=1

#update apache to host cacti
echo "Alias /cacti /usr/share/cacti" > /etc/httpd/conf.d/cacti.conf
echo " " >> /etc/httpd/conf.d/cacti.conf
echo "<Directory /usr/share/cacti/>" >> /etc/httpd/conf.d/cacti.conf
echo " <IfModule mod_authz_core.c>" >> /etc/httpd/conf.d/cacti.conf
echo " # httpd 2.4" >> /etc/httpd/conf.d/cacti.conf
echo " Require all granted" >> /etc/httpd/conf.d/cacti.conf
echo " </IfModule>" >> /etc/httpd/conf.d/cacti.conf
echo "</Directory>" >> /etc/httpd/conf.d/cacti.conf
systemctl restart httpd.service

echo "*/5 * * * * cacti /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1" > /etc/cron.d/cacti

#It annoys me to have to type /cacti at the end of the URL so I make cacti the default page. Skip this section if you enjoy typing /cacti.
sed -i 's/DocumentRoot "\/var\/www\/html"/DocumentRoot "\/usr\/share\/cacti"/' /etc/httpd/conf/httpd.conf
sed -i 's/\/\/$url_path = "\/cacti\/";/\/\/$url_path = "\/";/' /usr/share/cacti/include/config.php
sed -i 's/\/\/$url_path = "\/cacti\/";/\/\/$url_path = "\/";/' /usr/share/cacti/include/global.php
systemctl restart httpd.service

#set the PHP timezone if it fills your logs with annoying messages. If you're in Detroit then you can be lazy.
sed -i 's/;date.timezone =/date.timezone = America\/Detroit/' /etc/php.ini

/usr/sbin/useradd -b /usr/share -d /usr/share/cacti -m -r -s /sbin/nologin cacti
chown -R cacti /usr/share/cacti/rra
chown -R cacti /usr/share/cacti/log

#Open a web page to the IP address of the cacti server and log in as admin/admin


Top
 Profile  
 
 Post subject: Re: [HOWTO] CentOS 7 and 0.8.8f
PostPosted: Mon Jan 25, 2016 9:51 am 
Offline

Joined: Mon Jan 25, 2016 9:46 am
Posts: 1
Your recipe is just what the doctor ordered. I've been struggling to install 0.8.8f properly on a CentOS 7 VM and was just about to give up.

I have had success with yum based Cacti installs but the most recent package I've found for those purposes is 0.8.8b and when I attempted to follow the instructions for a manual upgrade, things didn't go as well as I had hoped. Rather than pick through setup to try and debug it I thought I'd attempt a manual install to force myself to become more familiar with the lay of the land.

I struggled installing Cacti manually. I'd get Cacti running but even though I thought I had handled all of the various permissions and other configuration settings properly I found that the log was not being populated and RRD files were not getting to the proper folder. I'm sure that there was some sort of permission or path reference problem somewhere, but I couldn't find it.

Your instructions worked really well for me.

I do have a few observations and a modest suggestion or two.

Please note that I started with my standard CentOS 7 minimal install VM template, so all of your listed prerequisites were already in place other than tcpdump (and ignoring nano, which I don't use).

Why did you list wget as a necessary package but then you used curl?

Rather than providing instructions for installing or upgrading VMware tools, why not just add open-vmware-tools to the list of items to be added with yum. For what it's worth, the VMware tools package when run on CentOS suggests that you use open-vmware-tools.

After downloading and extracting the cacti distribution, why not create a link to it from /usr/share/cacti rather than just moving it. With the link in place I presume that upgrades will be easier.

I needed to execute execute "mysql -u root -p" to set up a password before I could use the database creation script you provide. Perhaps that's because of how I had already configured maria in by base system template.

Thanks again for what you created.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group