一、LAMP完全安装
groupadd mysql
useradd mysql -g mysql -M -s /bin/false
cd /home/admin
tar zxvf mysql-5.0.20a.tar.gz
cd mysql-5.0.20a
./configure --prefix=/usr/local/mysql --without-debug --with-extra-charsets=utf8
make
make install
/bin/rm /etc/my.cnf
scripts/mysql_install_db --user=mysql(如果没有--user=mysql将无法产生安装目录下的var目录)
cp support-files/my-medium.cnf /etc/my.cnf
chmod -R 750 /usr/local/mysql
chgrp -R mysql /usr/local/mysql
chown -R mysql /usr/local/mysql/var
/usr/local/mysql/bin/mysqld_safe &
/usr/local/mysql/bin/mysqladmin -uroot password 123456
cd /home/admin
tar zxvf httpd-2.2.3.tar.gz
cd httpd-2.2.3
./configure --prefix=/usr/local/apache --with-mysql=/usr/local/mysql --enable-module=so
make
make install
cd /home/admin
rpm -ivh xpm-3.4k-2.i386.rpm
sleep 3
tar zxvf libxml2-2.6.20.tar.gz
cd libxml2-2.6.20
./configure
make
make install
cd /home/admin
tar zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure
make
make install
cd /home/admin
tar zxvf freetype-2.2.1.tar.gz
cd freetype-2.2.1
make
make install
cd /home/admin
tar zxvf libpng-1.2.14.tar.gz
cd libpng-1.2.14
cp scripts/makefile.std makefile
make
make test
make install
cd /home/admin
mkdir /usr/local/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 zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b/
./configure --prefix=/usr/local/jpeg6
make
make install-lib
make install
cd /home/admin
tar zxvf gd-2.0.33.tar.gz
cd gd-2.0.33
./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg6 --with-png=/usr/local --with-zlib=/usr/local --with-freetype=/usr/local
make
make install
#cd /home/admin
#tar zxvf php-5.1.6.tar.tar
#cd cd php-5.1.6
#./configure --prefix=/usr/local/php --with-gd=/usr/local/gd/ --with-jpeg-dir=/usr/local/jpeg6/ --with-zlib=/usr/local/ --with-png=/usr/local/ --with-freetype-dir=/usr/local/ --with-mysql=/usr/local/mysql/ --with-apxs2=/usr/local/apache/bin/apxs --enable-track-vars --enable-sockets --enable-mbstring --with-pcre-regex(最后三个是cacti支持中文必须打开的)(还有在php5.2.0 安装的时候是 --enable-mbstring 用--with-mbstring 是无效的
php要求支持mbstring,mbstring需要libmbfl库,Cacti使用了pcre,所以在编译中一定要加入--with-pcre-regex --with-mbstring --with-libmbfl三项,都无需指定路径(切记).其它如gd,mysql等的支持当然不用说了)
遇到的问题
Configuring SAPI modules
checking for AOLserver support... no
checking for Apache 1.x module support via DSO through APXS... no
checking for Apache 1.x module support... no
checking for member fd in BUFF *... no
checking for mod_charset compatibility option... no
checking for Apache 2.0 filter-module support via DSO through APXS... no
checking for Apache 2.0 handler-module support via DSO through APXS...
Sorry, I cannot run apxs. Possible reasons follow:
1. Perl is not installed
2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page is displayed)
The output of /usr/local/apache/bin/apxs follows:
sh: line 1: 2076 Segmentation fault /usr/local/apache/bin/httpd -l
apxs:Error: Sorry, no shared object support for Apache.
apxs:Error: available under your platform. Make sure.
apxs:Error: the Apache module mod_so is compiled into.
apxs:Error: your server binary `/usr/local/apache/bin/httpd'..
configure: error: Aborting
将原来的httpd-2.0.47.tar.gz这个版本换成了httpd-2.0.59.tar.bz2问题解决。
#make
#make install
#cp php.ini-dist /usr/local/app/php/lib/php.ini
vi /usr/local/apache/conf/httpd.conf
添加两个php模块
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
在DirectoryIndex 后面加上index.php
保存退出
在/usr/local/apache/htdoc下创建index.php 测试页内容为
<?phpinfo()?>
二、
tar -zxvf rrdtool
cd rrdtool
./configure --prefix=/usr/local/rrdtool --disable-python --disable-tcl
make clean
make
make install
tar -zxvf net-snmp
cd net-snmp
./configure --prefix=/usr/local/net-snmp
make
make install
三、为cacti创建数据库
首先将cacti 解压,尔后移动到apache的根目录下/usr/local/apache/htdocs下
[root@localhost lamp]# tar zxvf cacti-0.8.6h.tar.gz
[root@localhost lamp]# mv cacti-0.8.6h /usr/local/apache/htdocs/cacti
cd /usr/local/cacti-
mysqladmin --user=root --password=mypassword create cacti
mysql --user=root --password=mypassword cacti < cacti.sql
mysql --user=root --password=mypassword mysql
mysql> GRANT ALL ON cacti.* to cactiuser@localhost identified by 'somepassword'; 指定一个cactiuser 用户,密码为somepassword
四、设置cacti的数据库连接
编辑include/config.php 修改数据设置部分如下:
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "somepassword";
五、
设置cacti的目录权限
Cacti目录下的rra目录是用来保存rrdtool文件的目录,log目录是用来记录日志的目录。这两个目录都要设置适当的权限,
useradd cactiuser
passwd cactiuser
cd /usr/local/apache2/htdocs/cacti
chown -R cactiuser rra/ log/
六、
设置定时抓取程序在/etc/crontab中加入如下选项:
crontab -u cactiuser -e
*/5 * * * * cactiuser php /usr/local/apache2/htdocs/cacti/poller.php > /dev/null 2>&1