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,根据现有模版监控服务器对象