2.安裝Mysql
#cd /usr/local/
#tar -zxvf mysql-5.1.22-rc-linux-i686-icc-glibc23.tar.gz
#ln -s mysql-5.1.22-rc-linux-i686-icc-glibc23 mysql
#cd mysql
#groupadd mysql
#useradd -g mysql mysql
#chown -R mysql .
#chgrp -R mysql .
#scripts/mysql_install_db --user=mysql
#chown -R root .
#chown -R mysql data
#bin/mysqld_safe --user=mysql &
#cp support-files/my-large.cnf /etc/my.cnf
#cp support-files/mysql.server /etc/rc.d/init.d/mysqld
#service mysqld restart
#chkconfig --add mysqld
#chkconfig --level 345 mysqld on
#service mysqld restart
編譯安裝 Apache
# cd /usr/local/src
# wget http://www.ip97.com/apache.org/httpd/httpd-2.2.6.tar.gz
# tar zxvf httpd-2.2.6.tar.gz
# cd httpd-2.2.6
依次安裝apr和apr-util
# cd srclib/apr
# CHOST="i686-pc-linux-gnu" CFLAGS="-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" CXXFLAGS="-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -funroll-loops -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" ./configure --prefix=/usr/local/apr --enable-threads --enable-other-child --enable-static
# make && make install
# cd ../apr-util
# CHOST="i686-pc-linux-gnu" CFLAGS="-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" CXXFLAGS="-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -funroll-loops -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/ --with-mysql=/usr/local/mysql
# make && make install
cd /usr/local/src/httpd-2.2.6
# CHOST="i686-pc-linux-gnu" CFLAGS="-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" CXXFLAGS="-O3 -msse2 -mmmx -Wall -W -mfpmath=sse -funroll-loops -mcpu=pentium4 -march=pentium4 -pipe -fomit-frame-pointer" ./configure --prefix=/usr/local/apache2 --enable-mods-shared=all --with-mysql=/usr/local/mysql --enable-cache --enable-file-cache --enable-mem-cache --enable-disk-cache --enable-static-support --enable-static-htpasswd --enable-static-htdigest --enable-static-rotatelogs --enable-static-logresolve --enable-static-htdbm --enable-static-ab --enable-static-checkgid --disable-cgid --disable-cgi --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --enable-ssl --with-ssl=/usr/include/openssl
# make
# make install
# echo '/usr/local/apache2/bin/apachectl start ' >> /etc/rc.local //將 apachectl 的調用加入到您的系統啓動文檔中。
註解:
./configure //配置源代碼樹
--prefix=/usr/local/apache2 //體系無關文檔的頂級安裝目錄PREFIX ,也就Apache的安裝目錄。
--enable-module=so //打開 so 模塊,so 模塊是用來提 DSO 支持的 apache 核心模塊
--enable-mods-shared=all //編譯全部的模板,對於無需我們能夠在httpd.conf去掉。
--enable-cache //支持緩存
--enable-file-cache //支持文檔緩存
--enable-mem-cache //支持記憶緩存
--enable-disk-cache //支持磁盤緩存
--enable-static-support //支持靜態連接(默認爲動態連接)
--enable-static-htpasswd //使用靜態連接編譯 htpasswd - 管理用於基本認證的用戶文檔
--enable-static-htdigest //使用靜態連接編譯 htdigest - 管理用於摘要認證的用戶文檔
--enable-static-rotatelogs //使用靜態連接編譯 rotatelogs - 滾動 Apache 日誌的管道日誌程式
--enable-static-logresolve //使用靜態連接編譯 logresolve - 解析 Apache 日誌中的IP地址爲主機名
--enable-static-htdbm //使用靜態連接編譯 htdbm - 操作 DBM 密碼數據庫
--enable-static-ab //使用靜態連接編譯 ab - Apache HTTP 服務器性能測試工具
--enable-static-checkgid //使用靜態連接編譯 checkgid
--disable-cgid //禁止用一個外部 CGI 守護進程執行CGI腳本
--disable-cgi //禁止編譯 CGI 版本的 PHP
--enable-ssl // 編譯 ssl模塊。
我們不再使用worker模式編譯apache,worker模式和php貌似有一些不協調不穩定之處。所以使用了默認的perfork模式。
將apache配置成開機自啓動:
在/etc/rc.d/rc.local文檔中加入一行
/usr/local/apache2/bin/apachectl start
這樣每次重新啓動系統以後,apache也會隨系統一起啓動.
或
# cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
然後 vi /etc/rc.d/init.d/httpd 添加(#!/bin/sh下面)
# chkconfig: 2345 10 90
# description: Activates/Deactivates Apache Web Server
最後,運行chkconfig把Apache添加到系統的啓動服務組裏面:
# chkconfig --add httpd
# chkconfig httpd on
3.安裝基本庫
(1)libxml
# cd libxml2-2.6.24
# ./configure --prefix=/usr/local/libxml2
# make
# make install
(2)jpeg6
# mkdir /usr/local/jpeg6/bin
# mkdir /usr/local/jpeg6/lib
# mkdir /usr/local/jpeg6/include
# mkdir /usr/local/jpeg6/man
# mkdir /usr/local/jpeg6/man/man1
# tar vzxf jpegsrc.v6b.tar.gz
# cd jpeg-6b
# ./configure --prefix=/usr/local/jpeg6 --enable-shared --enable-static
# make
# make install
make: ./libtool: Command not found
make: *** [jcapimin.lo] Error 127
錯誤分析:由於libtool版本過低導致的,重新下載新版本的libtool以默認方式安裝,執行以下命令:
./configure
make
make install
然後進入jpeg-6b的源碼目錄,然後執行以下步驟,切記!
cp /usr/share/libtool/config.sub .
cp /usr/share/libtool/config.guess .
./configure --enable-shared --enable-static
make
make install
到這裏
(3)freetype
# tar zvxf freetype-2.3.2.tar.gz
# cd freetype-2.3.2
# ./configure --prefix=/usr/local/freetype
# make
# make install
(4)zlib
# cd zlib-1.2.3
# ./configure --prefix=/usr/local/zlib
# make
# make install
(5) libpng
# cd libpng-1.2.16
# cp scripts/makefile.std makefile
# make
# make install
(6)fontconfig
#cd fontconfig-2.4.2
#./configure -with-freetype-config=/usr/local/freetype
#make
#make install
(7)gd
# cd gd-2.0.34
# ./configure --prefix=/usr/local/gd2 --with-png=/usr/local/lib --with-zlib=/usr/local/zlib --with-freetype=/usr/local/freetype --with-jpeg=/usr/local/jpeg6 --with-libxml=/usr/local/libxml2
# make
# make install
4.載入共享庫
編輯/etc/ld.so.conf
增加以下內容
/usr/local/freetype/lib
/usr/local/jpeg6/lib
/usr/local/gd2/lib
5.安裝Php
#cd php-5.2.6
#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-gd=/usr/local/gd2 --with-freetype-dir=/usr/local/freetype --with-jpeg-dir=/usr/local/jpeg6 --with-png-dir=/usr --with-zlib-dir=/usr/local/zlib --enable-gd-native-ttf --with-ttf --enable-gd-jis-conv--enable-xml --enable-mbstring --enable-sockets --enable-soap
6.讓apache支持php
# vi /usr/local/apache2/conf/httpd.conf
找到AddType application/x-gzip .gz .tgz
添加
AddType application/x-httpd-php-source .phps
找到DirectoryIndex index.html
修改成
7.安裝 rrdtool
#cd rrdtool-1.2.23
#./configure --prefix=/usr/local/rrdtool --disable-python --disable-tcl
# make
# make install
8.安裝net-snmp
#cd net-snmp-5.2.4
#./configure --prefix=/usr/local/net-snmp --enable-developer
#make
#make install
9.安裝Cacti
#cd cacti-0.8.7b
#mv cacti-0.8.7b /usr/local/apache2/htdocs/cacti
#cd /usr/local/apache2/htdocs/cacti/
#vi include/config.php
$database_default = "cactidb";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cactipw";
#useradd cactiuser
#chown -R cactiuser rra
#chgrp -R cactiuser /usr/local/apache2/htdocs/cacti/
#crontab -ucactiuser -e
*/5 * * * * /usr/local/php/bin/php /usr/local/apache2/htdocs/cacti/poller.php > /dev/null 2>&1
10.安裝cactid
#cd cacti-cactid-0.8.6g
#./configure --with-mysql=/usr/local/mysql
#make
#make install
#mkdir /usr/local/cactid/
#cp cactid cactid.conf /usr/local/cactid/
# vi /usr/local/cactid/cactid.conf
DB_Database cactidb
DB_User cactiuser
DB_Pass cactipw
11.數據庫配置
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('cactipw');
注:以上語句輸出 Query OK, 0 rows affected (0.01 sec) 表示成功
mysql> exit
Query OK, 1 row affected (0.00 sec)
mysql> grant all on cactidb.* to cactiuser@localhost identified by “cactipw”;
Query OK, 1 row affected (0.00 sec)
12.完成cacti的安裝
輸入:http://IP/cacti/
admin/admin
修改密碼
更具具體安裝路徑設置
snmpwalk Binary Path
RRDTool Binary Path等等路徑
進入cacti,根據現有模版監控服務器對象