|
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel
二 安装
1.安装mysql
tar zxvf mysql-5.0.92.tar.gz
cd mysql-5.0.92
./configure --prefix=/usr/local/mysql --sysconfdir=/etc --with-unix-socket-path=/usr/local/mysql/var/mysql/mysql.sock --without-debug --enable-isam --with-mysqld-user=mysql --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static
make && make install
useradd mysql
/usr/local/mysql/bin/mysql_install_db
cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chown -R mysql.mysql /usr/local/mysql/var
/etc/rc.d/init.d/mysqld start
cd..
2.安装apache
tar zxvf httpd-2.2.17.tar.gz
cd httpd-2.2.17
./configure --prefix=/usr/local/http --enable-so --enable-mods-shared=all --enable-vhost-alias --enable-deflate --enable-expires --enable-rewrite --enable-authn-dbm=shared --enable-ssl --with-ssl
make && make install
cp /usr/local/http/bin/apachectl /etc/rc.d/init.d/httpd
chmod 755 /etc/rc.d/init.d/httpd
/etc/rc.d/init.d/httpd start
在地址栏输入IP,可以看到
IT works
说明apache正常启动
3.安装php
tar zxvf php-5.2.17.tar.gz
cd php-5.2.17
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/http/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mcrypt --with-config-file-path=/usr/local/php5 --enable-safe-mode --enable-zip --with-bz2 --with-jpeg-dir --with-png-dir --with-freetype-dir --without-iconv --with-libxml-dir --with-zlib-dir --with-xmlrpc --with-gd --with-curl --enable-mbstring --with-curlwrappers --with-xsl --enable-sockets --disable-rpath --disable-debug
make && make install
cp php.ini-production /usr/local/php/etc/php.ini
vi /usr/local/http/conf/httpd.conf
找到AddType application/x-gzip .gz .tgz 在下行填加
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
找到index.html 在后边加空格,填加
index.php
4.填加PHP测试页
vi /usr/http/htdocs/index.php
填写代码
5.重启apache
service httpd restart
6.在地址栏输入
ip:/index.php
可以看到测试页,说明PHP正常启动
1. cacti安装:
tar -xzvf cacti-0.8.7g.tar.gz
cd cacti-0.8.7g
2. mv cacti-0.8.7g /usr/local/http/htdocs/cacti (apache默认www目录)
3. cd /usr/local/http/htdocs/cacti
chmod 777 rra
chmod 777 log
chmod 777 poller.php
4. vi /usr/local/http/htdocs/include/config.php
修改下面设置
$database_type = "mysql";
$database_default = "cacti"; #(连接cacti库)
$database_hostname = "127.0.0.1"; #(连接到那个地址)
$database_username = "cacti"; #(使用的数据库名)
$database_password = ""; #(密码)
$database_port = "3306";
5. 然后登录数据库;
mysql> create database cacti;
mysql> use mysql;
mysql> grant all privileges on cacti.* to cacti@localhost>
mysql> grant all privileges on cacti.* to cacti@127.0.0.1> mysql> update user set password=password("") where user="cacti";
mysql> flush privileges;
mysql> use cacti;
mysql> source /usr/local/http/htdocs/cacti.sql; #(导入数据库)
6. 浏览器下配置
#用浏览器打开 http://ip/cacti ,会显示 cacti的安装指南,设置好就不会再出现了。
#点击 “Next”
#选择“New Install”,点击“Next”
#指定 rrdtool、 php、 snmp 工具的 Binary 文件路径,确保所有的路径都是显示“ FOUND”,没有 “NOT FOUND”的,点击 Finish 完成安装。
#Cacti 默认的用户名与密码是 admin,输入用户名与密码,点击 login
#php路径改为 /usr/local/php/bin/php ( 上面php配置安装的时候已经安装到这里了)
#为了安全的原因,第一次登录成功后,cacti 会强制要求你更改一个新的 password ,输入新密码并确认密码,点击 save ,进入 cacti 控制台界面:
#点击 graphs ,查看cacti 监控本机的图表:
7. crontab -e
*/5 * * * * root /usr/local/php/bin/php /usr/local/http/htdocs/cacti/poller.php > /dev/null 2>&1
8. vi /etc/crontab
*/5 * * * * root /usr/local/php/bin/php /usr/local/http/htdocs/cacti/poller.php > /dev/null 2>&1
安装rrdtool包:
yun install perl-rrdtool-1.2.30-1.el5.rf.i386.rpm rrdtool-1.2.30-1.el5.rf.i386.rpm rrdtool-devel-1.2.30-1.el5.rf.i386.rpm #(这三个包一定要同时安装,要不然会报错。)
snmp安装配置:
使用 Cacti 监控 Linux 主机
#在被监控的linux主机上安装net-snmp
1. yum install net-snmp*
vi /etc/snmp/snmp.conf
#将下边这行中的default
com2secnotConfigUser default public
#改为
com2secnotConfigUser 127.0.0.1 public
#将下边这行中的systemview
access notConfigGroup "" any noauth exact systemview none none
#改为all
access notConfigGroup "" any noauth exact all none none
#将下边这行的注释“#”号去掉
#view all included .1 80
#重启snmpd服务
service snmpd restart
注意:
如果出现问题请注意一下snmp协议的版本,都用version 1是一种解决方法
如果都用version 1,需要把所有监控机和被监控机的snmpd.conf改一下
#vi /etc/snmp/snmpd.conf
#将下边这行
view systemview included .1.3.6.1.2.1.1#改为
view systemview included .1.3.6.1.2.1
运行./poller.php 出现如下问题。
./poller.php: line 1: ?php: 没有那个文件或目录
./poller.php: line 2: /bin: is a directory
./poller.php: line 3: +-------------------------------------------------------------------------+: command not found
./poller.php: line 4: syntax error near unexpected token `|'
./poller.php: line 4: ` | Copyright (C) 2004-2010 The Cacti Group
需要vi poller.php文件最顶 一行加入 #!/usr/bin/php -q 即可
装libmcrypt mhash mcrypt解决无法加载mcrypt
[root@localhost phpMyadmin]# cd /home/
[root@localhost home]# tar -zxvf libmcrypt-2.5.8.tar.gz -C /usr/local/src/
[root@localhost home]# cd /usr/local/src/libmcrypt-2.5.8/
[root@localhost libmcrypt-2.5.8]# ./configure
[root@localhost libmcrypt-2.5.8]# make && make install
[root@localhost libmcrypt-2.5.8]# echo "/usr/local/lib" >> /etc/ld.so.conf
[root@localhost libmcrypt-2.5.8]# ldconfig
[root@localhost libmcrypt-2.5.8]# cd /home/
[root@localhost home]# tar -zxvf mhash-0.9.9.9.tar.gz -C /usr/local/src/
[root@localhost home]# cd /usr/local/src/mhash-0.9.9.9/
[root@localhost mhash-0.9.9.9]# ./configure
[root@localhost mhash-0.9.9.9]# make && make install
[root@localhost mhash-0.9.9.9]# cd /home/
[root@localhost home]# tar -zxvf mcrypt-2.6.8.tar.gz -C /usr/local/src/
[root@localhost home]# cd /usr/local/src/mcrypt-2.6.8/
[root@localhost mcrypt-2.6.8]# ./configure
[root@localhost mcrypt-2.6.8]# make && make install
[root@localhost mcrypt-2.6.8]# cd /usr/local/src/php-5.3.2/
[root@localhost php-5.3.2]# ./configure --prefix=/usr/local/php5
--enable-mbstring
--with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql
--with-mcrypt
--with-config-file-path=/usr/local/php5
|
|
|