cacti-0.8.7e 安装笔记

cacti-0.8.7e 安装笔记

环境 AS4-UPDATE5
下载需要的软件
cacti主页
http://cactiusers.org/index.php
cacti下载
# wget http://www.cacti.net/downloads/cacti-0.8.7e.tar.gz
cacti插件下载
# wget http://mirror.cactiusers.org/downloads/plugins/cacti-plugin-0.8.7e-PA-v2.5.zip
# wget http://cactiusers.org/downloads/monitor.tar.gz
# wget http://cactiusers.org/downloads/settings.tar.gz
# wget http://cactiusers.org/downloads/thold.tar.gz

apache主页
http://httpd.apache.org/
apahce下载
# wget http://archive.apache.org/dist/httpd/httpd-2.2.6.tar.gz

mysql主页
http://www.mysql.com/
mysql下载
mysql-5.1.26

php主页
http://cn2.php.net/
php下载
# wget  wget http://cn2.php.net/distributions/php-5.3.0.tar.gz

zlib主页
http://www.zlib.net/
zlib下载
# wget http://www.zlib.net/zlib-1.2.3.tar.gz

libpng主页
http://www.libpng.org/
libpng下载
# wget http://prdownloads.sourceforge.net/libpng/libpng-1.2.40.tar.gz?download

freetype主页
http://www.freetype.org/index2.html
freetype下载
# wget http://ftp.twaren.net/Unix/NonGNU/freetype/freetype-2.3.9.tar.gz

xml主页
http://xmlsoft.org/
xml下载
# wget ftp://xmlsoft.org/libxml2/libxml2-2.7.4.tar.gz

libgd主页
http://www.libgd.org/Main_Page
libgd下载
# wget http://www.libgd.org/releases/gd-2.0.35.tar.gz

jpeg库下载
# wget ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz

rrdtool主页
http://oss.oetiker.ch/rrdtool/index.en.html
rrdtool下载
# wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.2.27.tar.gz

安装部分

apache安装
#tar zxvf httpd-2.2.6.tar.gz
#cd httpd-2.2.6
#./configure
--prefix=/usr/local/apache
--enable-so
--enable-ssl
--with-ssl=/usr/local/ssl
--enable-track-vars
--enable-rewrite
--with-zlib
--enable-modules=all
--enable-mods-shared=all 
--with-suexec-caller=daemon 
#make
#make install

编辑apache配置文件httpd.conf,以apache支持php
# vi /etc/httpd/httpd.conf
1、添加如下二行
  AddType application/x-httpd-php  .php
  AddType application/x-httpd-php-source  .phps

2、定位至DirectoryIndex index.html
  修改为:
   DirectoryIndex  index.php  index.html

3、按照使用习惯,这里将网站根目录指定到/var/www:
找到DocumentRoot “/usr/local/apache/htdocs”
修改为:DocumentRoot “/var/www”

找到<Directory “/usr/local/apache/htdocs”>
修改为:<Directory “/var/www”>

说明:这个对本文来说并非是不可少的。


#echo "/usr/local/apache/bin/apachectl start" >> /etc/rc.local(系统启动时服务自动启动)


mysql安装
#groupadd mysql
#useradd -g mysql -s /bin/false -M mysql
#tar zxvf mysql-5.1.26.tar.gz
#cd mysql-5.1.26

#./configure
--prefix=/usr/local/mysql
--enable-thread-safe-client
--enable-local-infile
--enable-static
--enable-assembler
--with-charset=gbk
--with-extra-charset=all
--with-low-memory
--with-mysqld-user=mysql
--with-big-tables
--with-charset=latin1
--with-collation=latin1_swedish_ci
--with-pthread
--with-client-ldflags=-all-static
--with-mysqld-ldflags=-all-static
--without-ndb-debug
--without-debug
#make
#make install
#cp support-files/my-medium.cnf  /etc/my.cnf
#cd  /usr/local/mysql
#chown -R mysql .
#chgrp -R mysql .
#bin/mysql_install_db --user=mysql
#chown -R root .
#chown -R mysql var
#bin/mysqld_safe --user=mysql &

#cd  ……/mysql-5.1.26     (这里的目录指的是原压缩包解压后的目录)
#cp  support-files/mysql.server  /etc/rc.d/init.d/mysqld
#chmod  700  /etc/rc.d/init.d/mysqld
加入自动启动服务队列:
#chkconfig --add mysqld
#chkconfig  --level  345  mysqld  on

启动
/usr/local/mysql/bin/mysqld_safe &
如果启动报如下错
 InnoDB: Setting file ./ibdata1 size to 10 MB
需要执行mysql安装目录下的这个命令
scripts/mysql_install_db

测试
#/usr/local/mysql/bin/mysqladmin  ping
#/usr/local/mysql/bin/mysqladmin  version
#/usr/local/mysql/bin/mysql

添加root密码
#/usr/local/mysql/bin/mysqladmin -uroot -p 旧密码 password 新密码
说明:此时mysql的root用户的密码为空

配置库文件搜索路径
# echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
# ldconfig

添加/usr/local/mysql/bin到环境变量PATH中
#export PATH=$PATH:/usr/local/mysql/bin

日志管理
开启错误日志 (在[safe_mysqld]项下添加)
# vi /etc/my.cnf
[safe_mysqld]
err-log=/var/log/mysqld/err.log

开启常规日志和更新日志 (在[mysqld]项下添加)
# vi /etc/my.cnf
[mysqld]
log=/var/log/mysqld/log.log
log-update=/var/log/mysqld/update.log

创建日志文件并设置权限
# mkdir /var/log/mysqld
# touch /var/log/mysqld/err.log /var/log/mysqld/log.log /var/log/mysqld/update.log
# chown -R mysql.mysql /var/log/mysqld

# service mysqld restart


安装zlib2
# tar zxvf tar zxvf zlib-1.2.3.tar.gz,进入目录
# ./configure --prefix=/usr/local/zlib
# make
# make install

安装PNG
# tar zxvf tar zxvf libpng-1.2.40.tar.gz,进入目录
# cp scripts/makefile.linux ./makefile
# ./configure �Cprefix=/usr/local/png
# make
# make install

安装JPEG6
# tar zxvf jpegsrc.v6b.tar.gz
# cd jpeg-6b
# mkdir -pv /usr/local/libjpeg/{,bin,lib,include,man/man1,man1}
# ./configure �Cprefix=/usr/local/libjpeg �Cenable-shared �Cenable-static
# make
# make install

安装freetype
# tar xzvf freetype-2.3.9.tar.gz
# cd freetype-2.3.9
# ./configure --prefix=/usr/local/freetype
# make && make install

安装libxml
# tar zxvf libxml2-2.7.4.tar.gz
# cd libxml2-2.7.4
# ./configure --prefix=/usr/local/xml
# make
# make install
# cp xml2-config /usr/bin

php的安装
# tar zxvf php-5.3.0.tar.gz
# cd php-5.3.0
#  ./configure
--prefix=/usr/local/php
--with-apxs2=/usr/local/apache/bin/apxs
--with-mysql=/usr/local/mysql
--with-mysqli=/usr/local/mysql/bin/mysql_config 
--with-png-dir=/usr/local/png
--with-jpeg-dir=/usr/local/jpeg 
--with-zlib-dir=/usr/local/zlib
--with-freetype-dir=/usr/local/freetype
--with-xml-dir=/usr/local/xml
--with-gd
--enable-mbstring=all
--enable-sockets
--with-iconv-dir
--enable-bcmath
--with-ttf 
--with-openssl
--enable-sqlite-utf8 
--enable-mbstring
# make
# make install
# cp php.ini-dist  /usr/local/php/lib/php.ini

优化设置
# vi /usr/local/php/lib/php.ini
;default_charset = "iso-8859-1"
在这行下面加一行
default_charset = "gbk"

max_execution_time = 600 ; // 改为600 (增加处理脚本的时间限制)
max_input_time = 600 ; //最大输出时间600秒
memory_limit = 40M ;
register_global =On
post_max_size = 2M ; //php可接受的 post 方法大小 2M
file_uploads = On ; //允许上载文件
upload_max_filesize = 2M ; //最大上载文件2M
session.auto_start = 1 ; //session自动启动

测试
vi test.php    放到apache的目录下
<?
phpinfo();
?>

安装rrdtool
# tar zxvf rrdtool-1.2.27.tar.gz
# cd rrdtool-1.2.27
# ./configure --prefix=/usr/local/rrdtool
# make;make install
如果下面这个错误
make[3]: *** [tclrrd.o] Error 1
就需要在配置里加上
configure --disable-tcl

配置mysql数据库
# /usr/local/mysql/bin/mysql
mysql> set password for root@localhost=password('cactipw');
mysql> Query OK, 0 rows affected (0.00 sec)
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');
mysql> flush privileges; (See cacti docs/INSTALL)
mysql> exit

安装cacti
# tar zxvf cacti-0.8.7e.tar.gz
# mv cacti-0.8.7e.tar.gz /var/www/cacti
# cd /var/www/cacti
# /usr/local/mysql/bin/mysql cactidb < cacti.sql
# vi include/config.php
  $database_type = “mysql”;
  $database_default = “cactidb”;
  $database_hostname = “localhost”;
  $database_username = “cactiuser”;
  $database_password = “cactipw”;
#crontab -e -u 用户名
添加如下内容:
*/5 * * * * /usr/local/php/bin/php /var/www/cacti/poller.php > /dev/null 2>&1
编辑apache配置文件
# vi /usr/local/apache/conf/httpd.conf
加入下面内容
Alias /cacti /var/www/cacti
<Directory /var/www/cacti>
DirectoryIndex index.php
AllowOverride all
order deny,allow
deny from all
allow from all
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc on
php_flag track_vars on
</Directory>
重启apache服务
# /usr/local/apache/bin/apachectl restart

到此cacti就安装完成了,现在可以登录去配置cacti了
http://localhost/cacti
默认账号密码都是admin

默认下cacti没有monitor、thold等插件,需要安装
安装插件
进入下载插件的目录
安装cacti-plugin
# unzip cacti-plugin-0.8.7e-PA-v2.5.zip
# cp cacti-plugin-0.8.7e-PA-v2.5.diff pa.sql /var/www/cacti/
# cd /var/www/cacti/
# /usr/local/mysql/bin/mysql cactidb < pa.sql
# patch -p1 -N < cacti-plugin-0.8.7e-PA-v2.5.diff
# vi /var/www/cacti/include/config.php
  修改下面的内容
   $config['url_path'] = '/';
  改为
  $config['url_path'] = '/cacti/';
  不然你的页面无法正常显示

安装monitor thold settings
# tar zxvf monitor-0.8.2.tar.gz
# tar zxvf thold-0.4.1.tar.gz
# tar zxvf settings-0.5.tar.gz
# mv monitor/ thold/ settings/ /var/www/cacti/plugins/
# cd /var/www/cacti/plugins/monitor/
# /usr/local/mysql/bin/mysql cactidb < monitor.sql
# cd /var/www/cacti/plugins/thold/
# /usr/local/mysql/bin/mysql cactidb < thold.sql
# vi /var/www/cacti/include/config.php
  找到下面的内容
   $plugins = array();
  在下面添加
   $plugins[] = 'thold';
   $plugins[] = 'monitor';
   $plugins[] = 'settings';
保存退出

现在在登录你的cacti
http://localhost/cacti
就会发现标签出现了monitor,但没有出现thold,是因为需要在cacti里面配置
登录cacti后点击
Plugin Management进入管理界面
找到Thresholds配置页面
点install和enable就ok了
这时候刷新页面就会发现thold也出现在标签栏中

需要注意的地方
进入settings在进入paths里
查看那些路径不对,不对的会显示红色并提示没有找到,一定修改正确,不然cacti会不正常!

到此cacti就已经成功的安装了!

你可能感兴趣的:(职场,休闲,安装笔记,cacti-0.8.7e)