系统环境:CentOS 5.5
所有软件都采取yum安装
1、安装Nginx平台
编译PHP的时候请检查有没加上--enable-sock参数。
安装完毕后:
cd /usr/bin
ln -s /usr/local/php/bin/php php
2、安装rrd和snmp相关东西
这里要先添加yum源,要不然Yum不到我们想要的东西
vi /etc/yum.repos.d/CentOS-Base.repo
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/RedHat/el$releasever/en/$basearch/dag
gpgcheck=1
gpgkey=http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
enabled=1
然后yum一下我们想要的东西
yum -y install php-snmp net-snmp net-snmp-libs net-snmp-utils rrdtool
3、配置snmpd,监控机和被监控机都要配置。PS:用新版的源码包安装,他的配置文件不一样,可以用我们yum的旧一点包的配置文件搞过去。
原配置:
com2secnotConfigUser default public
access notConfigGroup "" any noauth exact systemview none none
#view all included .1 80
修改为:
com2secnotConfigUser 127.0.0.1 public #127.0.0.1 为cacti主机的配置
access notConfigGroup "" any noauth exact all none none
view all included .1 80
启动服务:
service snmpd start
4、安装cacti
tar zxvf cacti-0.8.7g.tar.gz
mv cacti-0.8.7g /home/www/cacti
创建数据库并导入cacti的sql,并授权cacti用户
mysql -uroot -p123456 -e "create database cacti;"
mysql -uroot -p123456 -e "GRANT ALL PRIVILEGES ON cacti.* TO cacti@127.0.0.1 IDENTIFIED BY cacti;"
mysql -uroot -p123456 cacti < /home/www/cacti/cacti.sql
配置cacti数据库连接
vi /home/www/cacti/include/config.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "127.0.0.1";
$database_username = "cacti";
$database_password = "cacti";
$database_port = "3306";
5、配置Nginx
vi /usr/local/nginx/conf/nginx.conf
server
{
listen 80;
server_name www.lihp.com;
index index.html index.php;
root /home/www/cacti;
access_log /home/logs/access_www.log;
if (-d $request_filename){
rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
}
error_page 500 502 503 504 404 403 http://www.lihp.com;
location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 30d;
}
location ~ .*.(js|css)?$ {
expires 6h;
}
location ~ .*.(log|txt)$
{
deny all;
}
location ~ .*.(php)?$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
}
6、浏览器运行
用浏览器打开 www.lihp.com,会显示 cacti的安装指南,设置好就不会再出现了。
点击 “Next”
选择“New Install”,点击“Next”
[1] [2] 下一页