apache+mysql+php+snmp+rrdtool+cacti配置
apache+mysql+php+snmp+rrdtool+cacti配置OS CentOS3.5
本机IP 192.168.1.99
机器名请用类似 Bleach.com 格式
安装 mysql
所有安装程序 在 /usr 下
CODE:
#groupadd mysql
#useradd -g mysql mysql
#cd /usr/local
#gunzip < /usr/mysql-standard-4.0.23-pc-linux-i686.tar.gz | tar xvf -
#ln -s /usr/local/mysql-standard-4.0.23-pc-linux-i686 mysql
#cd mysql
#scripts/mysql_install-db -user=mysql
#chown -R root .
# chown -R mysql data
#chgrp -R mysql .
#./bin/mysqld-safe -user=mysql &
#./bin/mysqladmin -u root password mysql
#cp ./support-file/mysql.server /etc/init.d/mysql
#cd /etc/rc3.d/
#ln -s /etc/init.d/mysql S85mysql
#ln -s /etc/init.d/mysql K85mysql
Mysql 安装结束
安装apache
CODE:
#tar -zxvf httpd-2.0.54.tar.gz
#cd httpd-2.0.54
# ./configure --prefix=/www --enable-so
# make && make install
# cp /www/bin/apachectl /etc/init.d/httpd
#cd /etc/rc3.d
#ln -s ../init.d/httpd S85httpd
#ln -s ../init.d/httpd K85httpd
#/www/bin/apachectl start
Apache 安装完毕
安装PHP
CODE:
# tar -zxvf php-4.3.10.tar.gz
#cd php-4.3.10
# ./configure --prefix=/www/php
>--with-apxs2=/www/bin/apxs
>--with-config-file-path=/www/php
>--enable-sockets
>--with-mysql=/usr/local/mysql
>--with-zlib-dir=/usr/include
>--with-gd
#make && make install
#cp php.ini-dist /usr/local/lib/php.ini
#vi /www/conf/httpd.conf
按 I 键 添加 AddType application/x-tar .tgz
AddType application/x-httpd-php .php
AddType image/x-icon .ico
DirectoryIndex index.php index.html index.html.var
保存退出 :wq
#/www/bin/apachectl restart
Php安装完毕
设置mysql
CODE:
#/usr/local/mysql/bin/mysql -u root -pmysql
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
Mysql设置完毕
检测apache + php + mysql
# cd /www/htdocs
# touch test.php
#vi test.php
phpinfo( );
?>
保存退出 :wq
# touch mydqltest.html
#vi mysqltest.html
$link=mysql_connect(localhost,root);
mysql_select_db(mysql);
$str=select * from user;;
$result=mysql_query($str,$link);
$show=mysql_num_rows($result);
mysql_close($link);
for ($i=0;$i < $show;$i++)
{
$arr[$i]=mysql_fetch_array($result);
};
?>
保存退出 :wq
重启mysql + apache 服务
#service mydql restart
#service httpd restart
进入浏览器检查
http://192.168.1.99/test/php 和 http://192.168.1.99/mysqltest.html
安装rrdtool
CODE:
# tar zxvf rrdtool-1.0.50.tar.gz
# cd rrdtool-1.0.50
# ./configure
#make && make install
Rrdtool安装完毕
安装net-snmp、snmpwalk和snmpget命令
CODE:
#rpm -qa | grep net-snmp
net-snmp-5.0.9-2.30E.15
net-snmp-devel-5.0.9-2.30E.15
net-snmp-libs-5.0.9-2.30E.15
net-snmp-utils-5.0.9-2.30E.15
#vi /etc/snmp/snmpd.conf
更改 1、com2sec notConfigUser default public
改为:com2sec notConfigUser 127.0.0.1 public
2、access notConfigGroup any noauth exact systemview none none
改为:access notConfigGroup any noauth exact all none none
3、#view all included .1 80
将前面的 # 注释 去掉。
保存退出 :wq
#service snmpd restart
注:如果你机器内没有snmpwalk和snmpge命令,请到安装盘里查找 net-snmp-utils 包,rpm -ivh net-snmp-utils-*.rpm 只后这两个命令就在系统里了。其他包也都在安装盘里 确保安装这四个包就OK
CODE:
安装/ 配置cacti
# useradd cactiuser -g users
#passwd cactiuser (pwd:cactipw)
# cp cacti-0.8.6g.tar.gz /www/htdocs/
# tar zxvf cacti-0.8.6g.tar.gz
# mv cacti-0.8.6g cacri
# cd cacti
# /usr/local/mysql/bin/mysql -u root -pmysql cactidb < cacti.sql
# chown -R cactiuser rra/ log/
#cd scripts
#chown cactiuser:users *
#vi /www/htdocs/cacti/include/config.php
$database_type = “mysql”;
$database_default = “cactidb”;
$database_hostname = “localhost”;
$database_username = “cactiuser”;
$database_password = “cactipw”;
更改用户、密码 等项 与上面给出的对应 保存退出
# crontab -u cactiuser -e
加入 */5 * * * * /www/php/bin/php /www/htdocs/cacti/poller.php > /dev/null 2>&1
保存退出:wq
全部设置完毕。
打开浏览器 http://192.168.1.99/cacti 进入cacti的初始设置页面
第一次默认登陆账号:admin 密码 admin
登陆后在新改个密码就OK
需要说明的还有路径
CODE:
snmpwalk Binary Path :/usr/bin/snmpwalk
snmpget Binary Path:/usr/bin/snmpget
RRDTool Binary Path:/usr/rrdtool-1.0.50/src/rrdtool
PHP Binary Path:/www/php/bin/php
Cacti Log File Path:/www/htdocs/cacti/log/cacti.log
Cactid Poller File Path:/www/htdocs/cacti/poller.php
如果你是按我的步骤做的 那上面的路径一定不会错。
完
页:
[1]