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

有些地方的註解會在以後完善

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