本文只介绍Cacti环境的安装方法及安装过程中遇到的错误解决方法。
很多内容可能网络上好多朋友已经写过了,我只不过把我安装时的一些细节和遇到的出现错误的地方记录下来总结!希望对其他想安装的朋友有用!累死我了,不过现在安装一次的时间大大缩短了!哈哈~~
开始安装:
本文中所用到的软件下载地址如果不能使用了,可以自己上google/baidu搜索个链接!目前应该都好用,因为我才用过。安装时,注意你的安装目录。
第一部分:编译安装ApacheMySQL
# tar zxvf httpd-2.2.6.tar.gz
# cd httpd-2.2.6
# ./configure --prefix=/usr/local/apache22 --enable-module=so --with-mpm=worker --enable-module=rewrite
# make && make install
启动apache
# /usr/local/apache22/bin/apachectl start
IE访问http://ip/出现”It works!”,说明apache安装成功。
开始安装mysql
# tar zxvf mysql-5.0.22.tar.gz
# cd mysql-5.0.22
# ./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data/ --without-innodb --without-debug --with-extra-charsets=gbk --with-extra-charsets=all --enable-assembler --with-pthread --enable-thread-safe-client --with-client-ldflags=-all-static
配置成功出现“Thank you for choosing MySQL!”提示。
# make && make install       //这步大概要10分钟左右吧,漫长啊。。。
Mysql配置
# cp ./support-files/mysql.server /etc/init.d/mysql
# groupadd mysql
# useradd –g mysql mysql
# chmod 777 /etc/init.d/mysql
# /usr/local/mysql/bin/mysql_install_db
# chown -R mysql:mysql /usr/local/mysql/data/
启动Mysql
# service mysql start
# /usr/local/mysql/bin/mysqladmin –u root –p password 'rootpw'       //设置密码为rootpw
Enter password:                 //默认密码为空,所以直接回车
# /usr/local/mysql/bin/mysql –u root –p
Enter password:                 //输入新密码后,登录成功
mysql安装配置完毕。
第二部分:安装GD库及相关插件
编译安装libxml
# tar zxvf libxml2-2.6.32.tar.gz
# cd libxml2-2.6.32
# ./configure --prefix=/usr/local/libxml2/
# make && make install
编译安装zlib
# tar zxvf zlib-1.2.3.tar.gz
# # cd zlib/1.2.3/
# ./configure --prefix=/usr/local/zlib2/
# make && make install
编译安装jpeg
这个版本jpegmake install时会error。手动创这些录,然后再重新make install就可以了,我这把缺失的命令都加上了,应该不会出这个error了。
# mkdir /usr/local/jpeg6
# mkdir /usr/local/jpeg6/include
# mkdir /usr/local/jpeg6/lib
# mkdir /usr/local/jpeg6/bin
# mkdir /usr/local/jpeg6/man/man1 -p
# tar zxvf jpegsrc.v6b.tar.gz
# cd jpeg-6b
# ./configure --prefix=/usr/local/jpeg6
# make
# make install-lib
# make install
编译安装libpng
# tar zxvf libpng-1.2.18.tar.gz
# cd libpng-1.2.18
# cp scripts/makefile.gcmmx makefile
# ./configure --disable-shared --prefix=/usr/local/libpng2/
# make && make install
编译安装freetype
# tar zxvf freetype-2.3.5.tar.gz
# cd freetype-2.3.5
# ./configure --disable-shared --prefix=/usr/local/freetype2/
# make && make install
编译安装libart_lgpl
# tar zxvf libart_lgpl-2.3.17.tar.gz
# cd libart_lgpl-2.3.17
# ./configure --disable-shared --prefix=/usr/local/libart/
# make && make install
编译安装gettext
# tar zxvf gettext-0.16.1.tar.gz
# cd gettext-0.16.1
# ./configure --prefix=/usr/local/gettext/
# make && make install  //这个编译时间好长啊。。。郁闷,可以出去吃个雪糕了haha
上面全部安装完成后,开始编译安装gd,此处注意configure时各个插件的地址是否正确:
# tar zxvf gd-2.0.35.tar.gz
# cd gd/2.0.35/
# ./configure --prefix=/usr/local/gd2 --with-zlib=/usr/local/zlib2/ --with-png=/usr/local/libpng2/ --with-jpeg=/usr/local/jpeg6/ --with-freetype=/usr/local/freetype2/ --with-libart=/usr/local/libart/ --with-gettext=/usr/local/gettext/ --with-libxml=/usr/local/libxml2
# cp /usr/lib/libattr.* /lib/   //如果没这步make会出下面的error信息
# make && make install
安装GD2时出错提示:
cd . && /bin/sh /tmp/cacti/gd/2.0.35/config/missing --run aclocal-1.9 -I config
aclocal:configure.ac:64: warning: macro `AM_ICONV' not found in library
 cd . && /bin/sh /tmp/cacti/gd/2.0.35/config/missing --run automake-1.9 --foreign
cd . && /bin/sh /tmp/cacti/gd/2.0.35/config/missing --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.* /lib/         //有两个libattr开头文件,有一个/lib里有,另一个复制过去就行了
编译安装Curl支持
# tar zxvf curl-7.15.0.tar.gz
# cd curl-7.15.0
# ./configure --prefix=/usr/local/curl
# make && make install
第三部分:编译安装并配置PHP
# tar zxvf php-5.2.10.tar.gz
# cd php-5.2.10
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache22/bin/apxs --with-jpeg-dir=/usr/local/jpeg6/ --with-png-dir=/usr/local/libpng2/ --with-gd --with-freetype-dir=/usr/local/freetype2/ --with-zlib-dir=/usr/local/zlib2/ --with-mysql=/usr/local/mysql --with-curl=/usr/local/curl --with-gettext=/usr/local/gettext --enable-sockets
我第一次安装时,编译PHP出错了,出错信息提示GD有问题:“configure: error: Unable to find gd.h anywhere under”上网查了下说中已GD了,把--with-gd后面留空,就可以configure了,上面的命令,我已经去掉了—with-gd的值,所以应该不会出这个error了。仔细想想好像我装系统时确实把图形那个组件给点上了!嘿嘿~~~
Configure成功后提示”Thank you for using PHP.”.
# make
# make test
Make test时出错了,不过感觉这个错误影响不是很大,暂时也没找到原因,可能是版本问题,因为上次安装时,我用的不同版本,所以遇到的错误信息也不一样,有点忘了,上次试用了三四个版本,头都搞大了。所以这次也没管它,直接继续安装了~还好后面都成功了,php好用~~~所以暂时就这样吧,如果有高手知道原因,望告之~呵呵~~即使后面不成功的话,这里也可以重编译再装:)换版本或想别的办法解决!!!
ob_start(): Ensure unerasable buffer cannot be flushed by ob_flush(). [tests/output/ob_start_basic_unerasable_005.phpt]
SPL: ArrayObject::exchangeArray() basic usage with object as underlying data store. [ext/spl/tests/arrayObject_exchangeArray_basic3.phpt]
继续:
# make install
# cp php.ini-dist /usr/local/php/lib/php.ini    //拷贝php配置文件
修改apache配置文件httpd.conf
# vi /usr/local/apache22/conf/httpd.conf
#AddType application/x-tar.tgz下加一行:
AddType application/x-httpd-php .php
#LoadModule foo_module modules/mod_foo.so下加一行: 如果原来有就去掉#
LoadModule php5_module  modules/libphp5.so
找到DirectoryIndex index.html在后面 index.php
保存httpd.conf文件.
apache
# /usr/local/apache22/bin/apachectl stop
# /usr/local/apache22/bin/apachectl start
hp安装完后,在 /usr/local/apache2/modules 添加了动态连接库 libphp5.so
如果在启动或者重启apache时候,出现以下信息:
[root@miix htdocs]# apachectl -k restart
httpd: Syntax error on line 53 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server: /usr/local/apache2/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied
这是由于selinux引起的,所以需要这样一下:
chcon -t textrel_shlib_t libphp5.so
php安装完后,在 /usr/local/apache2/conf/httpd.conf 添加了一行:
LoadModule php5_module        modules/libphp5.so
本人不想采用这种方式,于是将上述一行注释掉,然后在 httpd.conf 文件末尾添加:
Include conf/conf.d/*.conf
接着建立目录 /usr/local/apache2/conf/conf.d
添加 php.conf 文件,内容如下:
--------------------------------------------------------------------------------
#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#
LoadModule php5_module modules/libphp5.so
#
# Cause the PHP interpreter to handle files with a .php extension.
#
AddHandler php5-script .php
AddType text/html .php
#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php
#
# Uncomment the following line to allow PHP to pretty-print .phps
# files as PHP source code:
#
#AddType application/x-httpd-php-source .phps
--------------------------------------------------------------------------------
重启apache,在 /usr/local/apache2/htdocs 目录下建立一个 test.php 文件,如下
<?php phpinfo(); ?>
写一个测试页,放到apachehtdocs,打开浏览器访问应该可以看到php的版本等信息php测试页代码如下:<?php phpinfo();?>