farmer111 发表于 2019-1-12 10:08:04

RHEL 5 源代码安装cacti

RHEL5安装Cacti


环境:
RHEL5
# uname -a
Linux station202.example.com 2.6.18-53.el5 #1 SMP Wed Oct 10 16:34:02 EDT 2007 i686 i686 i386 GNU/Linux


安装Cacti需要安装的软件包:
apache,mysql,php,net-snmp,cacti,cacti-cactid,rrdtool,以及php需要的gd库:zlib,freetype,libpng,jpeg,

fontconfig,libgd,libxml。


一:安装mysql
下载地址:http://dev.mysql.com/downloads/mysql/5.0.html


# tar zxvf mysql-5.0.81-linux-i686-glibc23.tar.gz -C /usr/local/
# useradd mysql
# cd /usr/local
# ln -s mysql-5.0.81-linux-i686-glibc23 mysql
# cd mysql
# chown -R mysql.mysql .
# scripts/mysql_install_db --user=mysql//初始化授权表
# chown -R root .
# chown -R mysql data
# bin/mysqld_safe --user=mysql &

# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
# chkconfig --add mysqld
# chkconfig mysqld on
# service mysqld status
MySQL running (4078)                                       


# vim /etc/my.cnf

set-variable=max_connections=1000            ## 最大连接数
set-variable=max_user_connections=500            ## 每个用户最大连接数
set-variable=wait_timeout=200                ## 多少秒后关闭空闲(IDLE)
## 添加以上内容

# chown root.mysql /etc/my.cnf
# service mysqld restart

# bin/mysqladmin -u root -p variables
## 可以看到以下项说明修改成功
|max_connections                | 1000
|max_user_connections         | 500
|wait_timeout                   | 200
# ln -s /usr/local/mysql/bin/* /usr/local/bin/


二:安装apache
下载地址:http://httpd.apache.org/
# useradd apache
# tar zxvf httpd-2.2.4.tar.gz
# cd httpd-2.2.4
# ./configure --prefix=/usr/local/apache --enable-so    ## --enable-so一定要带,不

然不能动态加载模块
# make
# make install
# cd /usr/local/apache/
# vim conf/httpd.conf
ServerName 192.168.1.202                        ## 修改这行内容(本机IP或者域名)
# vim /etc/rc.local
/usr/local/apache/bin/apachectl -k start                ## 添加这行,开机启动apache
# /usr/local/apache/bin/apachectl -k start    ## 启动apache


三:安装PHP
先安装zlib,libpng,freetype,jpeg,fontconfig,libgd,libxml。以便于让PHP支持GD库(Cacti的WeatherMap插件必须要较新GD

库的支持)
1):安装zlib
# tar zxvf zlib-1.2.3.tar.gz
# cd zlib-1.2.3
# ./configure --prefix=/usr/local/zlib
# make
# make install

2):安装libpng                            ## 编译的时候需要zlib,--with-zlib指定
# tar zxvf libpng-1.2.18.tar.gz
# cd libpng-1.2.18/
# ./configure --prefix=/usr/local/libpng --with-zlib=/usr/local/zlib
# make
# make install



3):安装freetype
# tar zxvf freetype-2.3.5.tar.gz
# cd freetype-2.3.5
# ./configure --prefix=/usr/local/freetype
# make
# make install



4):安装libjpeg
# tar zxvf jpegsrc.v6b.tar.gz
# cd jpeg-6b/
# mkdir /usr/local/libjpeg
# mkdir /usr/local/libjpeg/include
# mkdir /usr/local/libjpeg/bin
# mkdir /usr/local/libjpeg/lib
# mkdir /usr/local/libjpeg/man
# mkdir /usr/local/libjpeg/man/man1
# ./configure --prefix=/usr/local/libjpeg --enable-shared --enable-static
## 这里configure一定要带--enable-shared参数,不然,不会生成共享库
# make
# make install


5):安装libxml2
# rpm -qa | grep libxml
libxml2-2.6.26-2.1.2
libxml2-python-2.6.26-2.1.2
# rpm -ivh libxml2-devel-2.6.26-2.1.2.i386.rpm

6):安装fontconfig                  ## 需要libxml2和freetype的支持
# tar zxvf fontconfig-2.4.2.tar.gz
# cd fontconfig-2.4.2
# ./configure --with-freetype-config=/usr/local/freetype/bin/freetype-config --

prefix=/usr/local/fontconfig
# make
# make install

7):安装gd
# tar zxvf gd-2.0.33.tar.gz
# cd gd-2.0.33
# ./configure --prefix=/usr/local/libgd --with-png=/usr/local/libpng --with-

freetype=/usr/local/freetype --with-jpeg=/usr/local/libjpeg --with-fontconfig=/usr/local/fontconfig

## 可以看到下面的信息,一定要看到才正确。
** Configuration summary for gd 2.0.33:

   Support for PNG library:          yes
   Support for JPEG library:         yes
   Support for Freetype 2.x library: yes
   Support for Fontconfig library:   yes
   Support for Xpm library:          no
   Support for pthreads:             yes

# make
# make install

8):编辑/etc/ld.so.conf,添加以下几行到此文件中。
    /usr/local/zlib/lib
    /usr/local/freetype/lib
    /usr/local/libjpeg/lib
    /usr/local/libgd/lib
# ldconfig               ## 使用动态装入器装载找到共享库


9):安装PHP
下载地址:http://cn2.php.net/distributions/php-5.2.9.tar.gz
# tar zxvf php-5.2.9.tar.gz
# cd php-5.2.9
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-

mysql=/usr/local/mysql --with-gd=/usr/local/libgd --enable-gd-native-ttf --with-ttf --enable-gd-jis-conv --with-

freetype-dir=/usr/local/freetype --with-jpeg-dir=/usr/local/libjpeg --with-png-dir=/usr/local/libpng --with-zlib-

dir=/usr/local/zlib --enable-xml --enable-mbstring --enable-sockets--with-libxml-dir=/usr/lib
# make                ## 可以去睡一觉
# make install            ## 起来换个姿势再睡。。。

###########################################
对php编译选项的解释:
--prefix=/usr/local/php//指定PHP的安装目录
--with-apxs2=/usr/local/apache2/bin/apxs   //支持Apache模块
--with-mysql=/usr/local/mysql   //支持MySQl
--with-gd=/usr/local/libgd    //支持GD库
--enable-gd-native-ttf    //激活对本地 TrueType 字符串函数的支持
--with-ttf    //激活对 FreeType 1.x 的支持
--with-freetype-dir=/usr/local/freetype   //激活对 FreeType 2.x 的支持
--with-jpeg-dir=/usr/local/libjpeg //激活对 jpeg-6b 的支持
--with-png-dir=/usr/local/lib   //激活对png 的支持
--with-zlib-dir=/usr/local/zlib //激活对zlib 的支持
--enable-mbstring   //激活mbstring模块
--enable-gd-jis-conv //使JIS-mapped可用,支持日文字体
--with-mail//支持Mail函数
--enable-xml    //支持XML
--enable-sockets   //支持套接字
--with-libxml-dir=/usr/lib      
###########################################

# ln -s /usr/local/php/bin/* /usr/local/bin/
# cp php.ini-recommended /usr/local/php/lib/php.ini

## 使apache支持php
# vi /usr/local/apache/conf/httpd.conf
AddType application/x-tar .tgz
AddType application/x-httpd-php .php
AddType image/x-icon .ico
## 添加上面几行

    DirectoryIndex index.html index.php                ## 添加个index.php


# /usr/local/apache/bin/apachectl -k restart

## 注意,如果你开了selinux,httpd在读取/usr/local/apache/modules/libphp5.so的时候,会被AVC拒绝。
## 有两种方法:
# setenforce 0            ## 把selinux设置成默许模式
或者:
# chcon -t textrel_shlib_t /usr/local/apache/modules/libphp5.so

# vi /usr/local/apache/htdocs/test.php
## 添加以下行(用代替[]):   

[?php            ##如果要使用
页: [1]
查看完整版本: RHEL 5 源代码安装cacti