RHEL5安装Cacti
环境:
RHEL5
[root@station202 ~]# 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
[root@station202 cacti]# tar zxvf mysql-5.0.81-linux-i686-glibc23.tar.gz -C /usr/local/
[root@station202 cacti]# useradd mysql
[root@station202 cacti]# cd /usr/local
[root@station202 local]# ln -s mysql-5.0.81-linux-i686-glibc23 mysql
[root@station202 local]# cd mysql
[root@station202 mysql]# chown -R mysql.mysql .
[root@station202 mysql]# scripts/mysql_install_db --user=mysql //初始化授权表
[root@station202 mysql]# chown -R root .
[root@station202 mysql]# chown -R mysql data
[root@station202 mysql]# bin/mysqld_safe --user=mysql &
[root@station202 mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@station202 mysql]# chkconfig --add mysqld
[root@station202 mysql]# chkconfig mysqld on
[root@station202 mysql]# service mysqld status
MySQL running (4078) [ OK ]
[root@station202 mysql]# vim /etc/my.cnf
[mysqld]
set-variable=max_connections=1000 ## 最大连接数
set-variable=max_user_connections=500 ## 每个用户最大连接数
set-variable=wait_timeout=200 ## 多少秒后关闭空闲(IDLE)
## 添加以上内容
[root@station202 mysql]# chown root.mysql /etc/my.cnf
[root@station202 mysql]# service mysqld restart
[root@station202 mysql]# bin/mysqladmin -u root -p variables
## 可以看到以下项说明修改成功
|max_connections | 1000
|max_user_connections | 500
|wait_timeout | 200
[root@station202 ~]# ln -s /usr/local/mysql/bin/* /usr/local/bin/
二:安装apache
下载地址:http://httpd.apache.org/
[root@station202 ~]# useradd apache
[root@station202 ~]# tar zxvf httpd-2.2.4.tar.gz
[root@station202 ~]# cd httpd-2.2.4
[root@station202 httpd-2.2.4]# ./configure --prefix=/usr/local/apache --enable-so ## --enable-so一定要带,不
然不能动态加载模块
[root@station202 httpd-2.2.4]# make
[root@station202 httpd-2.2.4]# make install
[root@station202 httpd-2.2.4]# cd /usr/local/apache/
[root@station202 apache]# vim conf/httpd.conf
ServerName 192.168.1.202 ## 修改这行内容(本机IP或者域名)
[root@station202 apache]# vim /etc/rc.local
/usr/local/apache/bin/apachectl -k start ## 添加这行,开机启动apache
[root@station202 apache]# /usr/local/apache/bin/apachectl -k start ## 启动apache
三:安装PHP
先安装zlib,libpng,freetype,jpeg,fontconfig,libgd,libxml。以便于让PHP支持GD库(Cacti的WeatherMap插件必须要较新GD
库的支持)
1):安装zlib
[root@station202 ~]# tar zxvf zlib-1.2.3.tar.gz
[root@station202 ~]# cd zlib-1.2.3
[root@station202 zlib-1.2.3]# ./configure --prefix=/usr/local/zlib
[root@station202 zlib-1.2.3]# make
[root@station202 zlib-1.2.3]# make install
2):安装libpng ## 编译的时候需要zlib,--with-zlib指定
[root@station202 ~]# tar zxvf libpng-1.2.18.tar.gz
[root@station202 ~]# cd libpng-1.2.18/
[root@station202 libpng-1.2.18]# ./configure --prefix=/usr/local/libpng --with-zlib=/usr/local/zlib
[root@station202 libpng-1.2.18]# make
[root@station202 libpng-1.2.18]# make install
3):安装freetype
[root@station202 ~]# tar zxvf freetype-2.3.5.tar.gz
[root@station202 ~]# cd freetype-2.3.5
[root@station202 freetype-2.3.5]# ./configure --prefix=/usr/local/freetype
[root@station202 freetype-2.3.5]# make
[root@station202 freetype-2.3.5]# make install
4):安装libjpeg
[root@station202 ~]# tar zxvf jpegsrc.v6b.tar.gz
[root@station202 ~]# cd jpeg-6b/
[root@station202 jpeg-6b]# mkdir /usr/local/libjpeg
[root@station202 jpeg-6b]# mkdir /usr/local/libjpeg/include
[root@station202 jpeg-6b]# mkdir /usr/local/libjpeg/bin
[root@station202 jpeg-6b]# mkdir /usr/local/libjpeg/lib
[root@station202 jpeg-6b]# mkdir /usr/local/libjpeg/man
[root@station202 jpeg-6b]# mkdir /usr/local/libjpeg/man/man1
[root@station202 jpeg-6b]# ./configure --prefix=/usr/local/libjpeg --enable-shared --enable-static
## 这里configure一定要带--enable-shared参数,不然,不会生成共享库
[root@station202 jpeg-6b]# make
[root@station202 jpeg-6b]# make install
5):安装libxml2
[root@station202 Server]# rpm -qa | grep libxml
libxml2-2.6.26-2.1.2
libxml2-python-2.6.26-2.1.2
[root@station202 Server]# rpm -ivh libxml2-devel-2.6.26-2.1.2.i386.rpm
6):安装fontconfig ## 需要libxml2和freetype的支持
[root@station202 ~]# tar zxvf fontconfig-2.4.2.tar.gz
[root@station202 ~]# cd fontconfig-2.4.2
[root@station202 fontconfig-2.4.2]# ./configure --with-freetype-config=/usr/local/freetype/bin/freetype-config --
prefix=/usr/local/fontconfig
[root@station202 fontconfig-2.4.2]# make
[root@station202 fontconfig-2.4.2]# make install
7):安装gd
[root@station202 ~]# tar zxvf gd-2.0.33.tar.gz
[root@station202 ~]# cd gd-2.0.33
[root@station202 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
[root@station202 gd-2.0.33]# make
[root@station202 gd-2.0.33]# make install
8):编辑/etc/ld.so.conf,添加以下几行到此文件中。
/usr/local/zlib/lib
/usr/local/freetype/lib
/usr/local/libjpeg/lib
/usr/local/libgd/lib
[root@station202 gd-2.0.33]# ldconfig ## 使用动态装入器装载找到共享库
9):安装PHP
下载地址:http://cn2.php.net/distributions/php-5.2.9.tar.gz
[root@station202 ~]# tar zxvf php-5.2.9.tar.gz
[root@station202 ~]# cd php-5.2.9
[root@station202 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
[root@station202 php-5.2.9]# make ## 可以去睡一觉
[root@station202 php-5.2.9]# 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
###########################################
[root@station202 php-5.2.9]# ln -s /usr/local/php/bin/* /usr/local/bin/
[root@station202 php-5.2.9]# cp php.ini-recommended /usr/local/php/lib/php.ini
## 使apache支持php
[root@station202 php-5.2.9]# 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
[root@station202 php-5.2.9]# /usr/local/apache/bin/apachectl -k restart
## 注意,如果你开了selinux,httpd在读取/usr/local/apache/modules/libphp5.so的时候,会被AVC拒绝。
## 有两种方法:
[root@station202 php-5.2.9]# setenforce 0 ## 把selinux设置成默许模式
或者:
[root@station202 php-5.2.9]# chcon -t textrel_shlib_t /usr/local/apache/modules/libphp5.so
# vi /usr/local/apache/htdocs/test.php
## 添加以下行(用代替[]):
[?php ##如果要使用
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com