---
title: "nginx下搭建cacti监控服务器"
author: "lavafree"
date: "2012-08-06T19:24:19Z"
tags: []
categories: ["开源软件"]
slug: "nginx-cacti"
draft: false
lastmod: "2012-08-07T17:07:47Z"
id: 1622548
url: "https://lavafree.iteye.com/blog/1622548"
---

一.安装nginx，php，mysql

详见张宴的 Nginx 0.8.x + PHP 5.2.13（FastCGI）搭建胜过Apache十倍的Web服务器（第6版）http://blog.s135.com/nginx\_php\_v6/

二.安装 RRDtool和net-snmp

yum install rrdtool

yum install net-snmp

yum install net-snmp-utils

 

修改snmp配置

shell&gt;vi /etc/snmp/snmpd.conf  
  把第89行前面的注释符号#去掉，变成   
  view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc  
  在62行进行修改：将  
  access notConfigGroup "" any noauth exact systemview   改为  
  access notConfigGroup "" any noauth exact mib2 none none

 

 snmp默认的弱口令为Public，安全改为一个更复杂的口令，

修改第41行的community字段..把public改成mypassword就可以了,将“default”改为你想哪台机器

可以看到你的snmp信息,如10.10.10.10，)  
重启服务service snmpd restart

查看snmp是否获取信息  
snmpwalk -v 1 127.0.0.1 -c public

如果可以看到大量的信息输出..就表明snmp已经配置好了

 

三.安装cacti

1\. 解压

shell&gt;cp cacti-version.tar.gz /usr/local/webserver/nginx/html/

shell&gt; tar xzvf cacti-version.tar.gz

2\. 创建数据库

shell&gt; mysqladmin --user=root create cacti

3\. 导入数据

shell&gt; mysql cacti &lt; cacti.sql

4\. 创建cacti用户

shell&gt; mysql --user=root mysql

mysql&gt; GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'somepassword';

mysql&gt; flush privileges;

5\. 剪辑 include/config.php 文件，更改数据库连接

$database\_type = "mysql";

$database\_default = "cacti";

$database\_hostname = "localhost";

$database\_username = "cactiuser";

$database\_password = "somepassword";

6\. 配置nginx.conf

server {

        listen 80;

 

        root html; #apps下面有cacti目录

        index index.php index.html;

        location ~.\*\\.(php|php5)?$ {

                root html;  #apps下面有cacti目录

                fastcgi\_pass 127.0.0.1:9000;

                fastcgi\_index index.php;

                include fastcgi\_params;

        }

}

7.增加www的权限

chown -R /usr/local/webserver/nginx/html/cacti/log /usr/local/webserver/nginx/html/cacti/raa

\*/5 * * * * php /usr/local/webserver/nginx/html/cacti/poller.php &gt; /dev/null 2&gt;&1

8\. 浏览器访问:

http://your-server/cacti/

进入安装界面

安装完成，就可以使用了，默认用户名：admin密码：admin