32位centos5.5下编译安装cacti

特此加上备注:这是32位编译方法,64位下有的地方极有可能不通,请不要骂我

1、在安装centos5.5的时候选择了默认安装,安装了图形界面和firefox,这有助于编译rrdtool

2、原始安装的时候安装了开发包和编译器

3、有很多安装项目并未做注解,会在以后更新注解和一些优化项目

4、在安装完操作系统后,请调整好系统的时区和时间,可以用下面的命令查看时区,

#   cat /etc/sysconfig/clock

#   date -R              这一个命令可以查看当前的时区和时间,更改时区和时间的具体方法请GOOGLE

#  ntpdate 210.72.145.44 中国国家NTP服务器,

5、关于cacti的web监控配置,在这一篇中不表述,因为涉及太多图片,

6、如有错误,谢谢各位提出,希望能和喜欢linux开源软件的朋友一起提高

正文

Ⅰ、编译安装mysql-5.1.46.tar.gz

#     tar zxvf mysql-5.1.46.tar.gz
#     cd mysql-5.1.46
#     groupadd -g 5050 mysql
#     useradd -g mysql -u 5050 -s /sbin/nologin -M mysql
#     autoreconf --force --install
#     libtoolize --automake --force
#     automake --force --add-missing
#     CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti -fomit-frame-pointer -ffixed-ebp"
#     ./configure --prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock --with-charset=gbk --localstatedir=/data --with-extra-charsets=all --enable-thread-safe-client
#     make && make install
#     cd /usr/local/mysql/
#     chown -R mysql:mysql .
#     chown -R mysql:mysql /data
#     bin/mysql_install_db --user=mysql
#     cp share/mysql/my-large.cnf /etc/my.cnf
#     echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
#     ldconfig
#     echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
#     source /etc/profile
#     cp share/mysql/mysql.server /etc/init.d/mysqld
#     chmod 755 /etc/init.d/mysqld
#     chkconfig --add mysqld
#     chkconfig mysqld off
#     chkconfig --level 3 mysqld on
 
Ⅱ编译安装apache和php
㈠编译安装支持库
1、编译安装jpegsrc.v6b.tar.gz
#     tar zxvf jpegsrc.v6b.tar.gz
#     mkdir -pv /usr/local/jpeg/{,bin,lib,include,man/man1,man1}
#     cd jpeg-6b/
#     ./configure --prefix=/usr/local/jpeg --enable-shared --enable-static
#     make && make install
2、 编译安装libpng-1.4.4.tar.gz
#     tar zxvf libpng-1.4.4.tar.gz
#     cd libpng-1.4.4
#     ./configure --prefix=/usr/local/libpng
#     make && make install
3、 编译安装freetype-2.4.3.tar.gz
#     tar zxvf freetype-2.4.3.tar.gz
#     cd freetype-2.4.3
#     mkdir -pv /usr/local/freetype
#     ./configure --prefix=/usr/local/freetype
#     make && make install
4、 编译安装zlib-1.2.5.tar.gz     
#     tar zxvf zlib-1.2.5.tar.gz
#     cd zlib-1.2.5
#     mkdir /usr/local/zlib
#     ./configure --prefix=/usr/local/zlib
#     make && make install
5、 编译安装curl-7.21.2.tar.gz
#     tar zxvf curl-7.21.2.tar.gz
#     mkdir -pv /usr/local/curl
#     cd curl-7.21.2
#     ./configure --prefix=/usr/local/curl
#     make && make install
6、编译安装libxml2-sources-2.7.8.tar.gz
#     tar zxvf libxml2-sources-2.7.8.tar.gz
#     cd libxml2-2.7.8/
#     mkdir -pv /usr/local/libxml2
#     ./configure --prefix=/usr/local/libxml2
#     make
#     make install
7、编译安装libxslt-1.1.9.tar.gz                         可以安装,也可以不安装
#     tar zxvf libxslt-1.1.9.tar.gz
#     mkdir -pv /usr/local/libxslt
#     cd libxslt-1.1.9
#     ./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
#     make
#     make install
8、编译安装fontconfig-2.8.0.tar.gz
#     tar zxvf fontconfig-2.8.0.tar.gz
#     cd fontconfig-2.8.0
#     mkdir -pv /usr/local/fontconfig
#     ./configure --prefix=/usr/local/fontconfig --disable-docs --with-freetype-config=/usr/local/freetype/bin/freetype-config
#     make
#     make install
9、编译安装 gettext-0.18.tar.gz         下载地址http://mirror.bjtu.edu.cn/gnu/gettext/
可以使用 yum install gettext安装
#     tar zxvf gettext-0.18.tar.gz
#     cd gettext-0.18
#     mkdir /usr/local/gettext
#     ./configure --prefix=/usr/local/gettext
#     make && make install
 
10、编译安装libart_lgpl-2.3.17.tar.tar
#     tar zxvf libart_lgpl-2.3.17.tar.tar
#     cd libart_lgpl-2.3.17
#     mkdir -pv /usr/local/libart
#     ./configure --prefix=/usr/local/libart             #也有加上参数--disable-shared    意义暂时不明白
#     make && make install
 
11、编译安装gd-2.0.35.tar.gz
#     tar zxvf gd-2.0.35.tar.gz
#     cd gd-2.0.35
#     mkdir -pv /usr/local/gd2
#     ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg --with-zlib-dir=/usr/local/zlib --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype --with-fontconfig=/usr/local/fontconfig --with-gettext=/usr/local/gettext --with-libart=/usr/local/libart
如果安装 GD2时出错提示:
configure.ac:64: warning: macro `AM_ICONV' not found in library
--run autoconf configure.ac:64: error: possibly undefined macro: AM_ICONV
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
make: *** [configure] error 1
解决:cp /usr/lib/libattr.a /lib/libattr.a
说明:在/usr/lib/libattr.*                         在/usr/lib下有2个libarrt.*文件,在/lib下面有其中一个,把另一个复制过去就OK
如果出错:make[2]: *** [gd_png.lo] Error 1           解决:修改gd源文件下
#       vim gd_png.c
         找到png.h修改为                /usr/local/libpng/include/png.h
#     make
#     make install

 

Ⅲ、安装apachephp
①     安装aprapr-util,这两个软件在apache源码包的srclib目录下
apr编译
#       ./configure --prefix=/usr/local/apr
#     make && make install
apr-util编译
#     ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
#     make && make install
 
②     安装httpd-2.2.15          #这是基于MPM-prefork进程模式,MPM-worker模式基于线程
③     修改一些安全参数和并发连接参数下面的文件都在apache的源文件中,改变标注为桔色的这项不是一个好习惯,特别是改源文件头的事情,
#     vim server/mpm/prefork/prefork.c
#define DEFAULT_SERVER_LIMIT 5000
#     vim server/mpm/worker/worker.c
#define DEFAULT_THREAD_LIMIT 400
#define DEFAULT_SERVER_LIMIT 200
#     vim include/ap_release.h
#define AP_SERVER_BASEPRODUCT "Microsoft-IIS/5.0"
#     vim os/unix/os.h
#define PLATFORM "Win32"
 
#     tar zxvf httpd-2.2.15.tar.gz
#     cd httpd-2.2.15
#     ./configure --prefix=/usr/local/apache2 --enable-so --enable-cache --enable-file-cache --enable-mem-cache --enable-disk-cache --enable-rewrite --enable-deflate --enable-expires --disable-cgi --disable-cgid --disable-access --disable-env --disable-autoindex --disable-asis --disable-action --disable-negotiation --disable-include --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
#     make && make install
#     /usr/local/apache2/bin/apachectl -l      #查看编译的模块
#     /usr/local/apache2/bin/apachectl start    #启动http服务,输入http://IP    出现页面表示apache安装成功
 
④安装php
1、 编译安装 zxvf php-5.3.3.tar.gz
#     tar zxvf php-5.3.3.tar.gz
#     mkdir -pv /usr/local/php5
#     cd php-5.3.3
#     ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-gd=/usr/local/gd2 --with-jpeg-dir=/usr/local/jpeg --with-zlib-dir=/usr/local/zlib --with-png-dir=/usr/local/libpng --with-freetype-dir=/usr/local/freetype --with-mysql=/usr/local/mysql --enable-mbstring=all --with-curl=/usr/local/curl --enable-mbregex --enable-ftp --enable-soap --with-xsl=/usr/local/libxslt --with-config-file-path=/usr/local/php5/etc --enable-zip --with-libXML-dir=/usr/local/libxml2 --enable-sockets  
#     make
#     make install
⑤整合apachephp
修改httpd.conf文件使支持php
#     vim /usr/local/apache2/conf/httpd.conf
查看是否有这一行,如果没有,需要增加上,理论上apache2.2.15与php5.3.3编译安装完成后,会自动生成这一行
LoadModule php5_module        modules/libphp5.so
在第310行下面增加下面的内容,309与310行的内容是
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
在这两行下面加入下面的内容,就能支持php
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
注:关于没有php.ini的解决,从源码目录复制
cp php.ini-dist /usr/local/php5/etc/        #注php5.33的php,ini文件应该不叫php.ini-dist,这个文件是php5.2.14的
⑥增加一个php测试页面(现在的家目录在$apache_home/htdocs下面)另外,测试完后不要忘记删掉这个页面
#     vim /usr/local/apache2/htdocs/test.php
<HTML>
<HEAD>
<TITLE>This is a test</TITLE>
</HEAD>
 
<BODY>
<?phpinfo()?>
 
</BODY>
</HTML>

 Ⅳ、安装cacti

注:请在编译安装cacti前安装好apache+mysql+php   配置web目录的具体方式在此不介绍,会在以后补充完整

1、mysql+apache+php
mysql                          /usr/local/mysql
apache                         /usr/local/apache2
web目录                            /var/www
php                              /usr/local/php5
 
1、编译安装rrdtool-1.2.27.tar.tar
解决依赖关系
#     tar zxvf rrdtool-1.2.27.tar.tar
#     cd rrdtool-1.2.27
#     ./configure --prefix=/usr/local/rrdtool
出错,错误1、
Find 3rd-Party Libraries
checking for art_vpath_add_point in -lart_lgpl_2... no
checking for pkg-config... pkg-config
configure: WARNING:
----------------------------------------------------------------------------
* I found a copy of pkgconfig, but there is no libart-2.0.pc file around.
 You may want to set the PKG_CONFIG_PATH variable to point to its
 location.
----------------------------------------------------------------------------
configure: WARNING:
----------------------------------------------------------------------------
* I could not find a working copy of libart-2.0. Check config.log for hints on w
 this is the case. Maybe you need to set LDFLAGS and CPPFLAGS appropriately
 so that compiler and the linker can find libart_lgpl_2 and its header files. I
 you have not installed libart-2.0, you can get it either from its original hom
     ftp://ftp.gnome.org/pub/GNOME/sources/libart_lgpl/2.3/
 You can find also find an archive copy on
 The last tested version of libart-2.0 is 2.3.17.
       LIBS=-lm
   LDFLAGS=
 CPPFLAGS= -I/usr/include/libart-2.0
----------------------------------------------------------------------------
checking for zlibVersion in -lz... yes
checking zlib.h usability... yes
checking zlib.h presence... yes
checking for zlib.h... yes
checking for png_access_version_number in -lpng... no
checking for pkg-config... (cached) pkg-config
configure: WARNING:
----------------------------------------------------------------------------
* I found a copy of pkgconfig, but there is no libpng.pc file around.
 You may want to set the PKG_CONFIG_PATH variable to point to its
 location.
----------------------------------------------------------------------------
configure: WARNING:
----------------------------------------------------------------------------
* I could not find a working copy of libpng. Check config.log for hints on why
 this is the case. Maybe you need to set LDFLAGS and CPPFLAGS appropriately
 so that compiler and the linker can find libpng and its header files. If
 you have not installed libpng, you can get it either from its original home on
     http://prdownloads.sourceforge.net/libpng/
 You can find also find an archive copy on
     http://oss.oetiker.ch/rrdtool/pub/libs
 The last tested version of libpng is 1.2.10.
       LIBS=-lz -lm
   LDFLAGS=
 CPPFLAGS=
----------------------------------------------------------------------------
checking for FT_Init_FreeType in -lfreetype... no
checking for pkg-config... (cached) pkg-config
configure: WARNING:
----------------------------------------------------------------------------
* I found a copy of pkgconfig, but there is no freetype2.pc file around.
 You may want to set the PKG_CONFIG_PATH variable to point to its
 location.
----------------------------------------------------------------------------
configure: WARNING:
----------------------------------------------------------------------------
* I could not find a working copy of freetype2. Check config.log for hints on wh
 this is the case. Maybe you need to set LDFLAGS and CPPFLAGS appropriately
 so that compiler and the linker can find libfreetype and its header files. If
 you have not installed freetype2, you can get it either from its original home
 
     http://prdownloads.sourceforge.net/freetype/
 
 You can find also find an archive copy on
 
     http://oss.oetiker.ch/rrdtool/pub/libs
 
 The last tested version of freetype2 is 2.1.10.
 
       LIBS=-lz -lm
   LDFLAGS=
 CPPFLAGS= -I/usr/include/freetype2
 
----------------------------------------------------------------------------
 
configure: error: Please fix the library issues listed above and try again.
 
解决freetype、libart、libpng的问题
#     cp /usr/local/freetype/lib/pkgconfig/freetype2.pc /usr/lib/pkgconfig/
#     cp /usr/local/libart/lib/pkgconfig/libart-2.0.pc /usr/lib/pkgconfig/
#     cp /usr/local/libpng/lib/pkgconfig/libpng.pc /usr/lib/pkgconfig/
打了这个很难看颜色的3项做了就能解决这几个问题
make的时候再次出错
/usr/bin/ld: cannot find -lpng
collect2: ld returned 1 exit status
make[4]: *** [blib/arch/auto/RRDs/RRDs.so] Error 1
make[4]: Leaving directory `/root/rrdtool/rrdtool-1.2.27/bindings/perl-shared'
make[3]: *** [perl_shared] Error 2
make[3]: Leaving directory `/root/rrdtool/rrdtool-1.2.27/bindings'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/root/rrdtool/rrdtool-1.2.27/bindings'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/rrdtool/rrdtool-1.2.27'
make: *** [all] Error 2
解决
ln -s /usr/local/libpng/lib/libpng.so /usr/lib/
make再次出错
/usr/bin/ld: cannot find -lfreetype
collect2: ld returned 1 exit status
make[4]: *** [blib/arch/auto/RRDs/RRDs.so] Error 1
make[4]: Leaving directory `/root/rrdtool/rrdtool-1.2.27/bindings/perl-shared'
make[3]: *** [perl_shared] Error 2
make[3]: Leaving directory `/root/rrdtool/rrdtool-1.2.27/bindings'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/root/rrdtool/rrdtool-1.2.27/bindings'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/rrdtool/rrdtool-1.2.27'
make: *** [all] Error 2
解决
ln -s /usr/local/freetype/lib/libfreetype.so /usr/lib/
#     make && make install
2、安装cacti
#     tar zxvf cacti-0.8.7g.tar.gz
#     mv cacti-0.8.7g /var/www/cacti
#     vim /var/www/cacti/include/config.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";                                #用户名自己弄一个
$database_password = "cacti";                          #密码自己弄一个
$database_port = "3306";
#     useradd cacti
#     chown -R cacti:cacti /var/www/cacti/                这一步相当的重要,涉及到权限问题
#     crontab -e -u cacti
*/5 * * * * /usr/local/php5/bin/php /var/www/cacti/poller.php > /dev/null 2>&1
注:可以先在cacti用户中运行一次
su - cacti
/usr/local/php5/bin/php /var/www/cacti/poller.php
3、启动mysql建立cacti数据库和用户,导入数据库模板
/usr/local/mysql/bin/mysql
create database cacti;
use cacti;
source /var/www/cacti/cacti.sql
 
grant all privileges on cacti.* to cacti@localhost identified by 'cacti';
grant all privileges on cacti.* to [email protected] identified by 'cacti';
flush privileges;
注解:grant all privileges on *.* to 用户名@登录主机 identified by "密码";给予全局权限
 
4、安装cactid
#     tar zxvf cacti-cactid-0.8.6k.tar.gz
#     cd cacti-cactid-0.8.6k
#     ./configure --with-mysql=/usr/local/mysql
#     make && make install
#     cp cactid cactid.conf /usr/local/cactid/
#     vim /usr/local/cactid/cactid.conf
DB_Host         127.0.0.1
DB_Database     cacti
DB_User         iuiely
DB_Pass         1qazse4
DB_Port         3306
5、安装snmp
#     yum -y install net-snmp-*
#    
com2sec notConfigUser default       public                    改为127.0.0.1 这一个是cacti监控服务器的IP地址
com2sec notConfigUser 127.0.0.1       public
access notConfigGroup ""      any       noauth    exact systemview none none      改为
access  notConfigGroup ""      any       noauth    exact all none none
#view all    included .1                               80                 去掉注释#
view all    included .1                               80

有些地方的注解会在以后完善

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章