redhat5.5 安装mcrypt模块

需要安装三个软件包,分别是:

libmcrypt-2.5.8.tar.gz

mhash-0.9.9.9.tar.gz

mcrypt-2.6.8.tar.gz

1.先安装libmcrypt  (说明:libmcript默认安装在/usr/local  )

1. #tar -zxvf libmcrypt-2.5.8.tar.gz
2. #cd libmcrypt-2.5.8
3. #./configure
4. #make
5. #make install
6.

2.安装mhash

1. #tar -zxvf mhash-0.9.9.9.tar.gz
2. #cd mhash-0.9.9.9
3. #./configure
4. #make
5. #make install

3.安装mcrypt

1. #tar -zxvf mcrypt-2.6.8.tar.gz
2. #cd mcrypt-2.6.8
3. #export LD_LIBRARY_PATH=/usr/local/lib // 通过set命令查看环境变量

4. ./configure
5. #make
6. #make install

注意:由于在配置mcrypt时,会找不到libmcrypt的链接库,导致无法编译,因为Libmcrypt的链接库在/usr/local/文件夹下。因些在配置mcrypt时要加入LD_LIBRARY_PATH=/usr/local导入键接库。

# export LD_LIBRARY_PATH=/usr/local/lib  ( 通过whereis libmcrypt查看路径然后配置)

4.安装PHP扩展模块:动态加载

使用php的常见问题是:编译php时忘记添加某扩展,后来想添加扩展,但是因为安装php后又装了一些东西如PEAR等,不想删除目录重装,于是可以采用phpize。
方法是:
1).要有与现有php完全相同的php压缩包 展开后进入里面的ext/mcrypt目录 (里面是mcrypt的php扩展)
#cd /smb/php-5.1.6/ext/mcrypt         //我的机器里装的是php-5.1.6.tar.gz

2).执行/usr/local/bin/phpize,执行完后,会发现当前目录下多了一些configure文件,如果没报错,则根据提示运行。
#/usr/local/bin/phpize            //可通过 whereis phpize 查看命令位置

./configure –with-php-config=/usr/bin/php-config

make  && make install

再去/usr/lib64/php/modules/ 查看mcrypt.so文件生成了,配置php.ini 载入拓展即可

编译php configure:error:cannot find output from lex,give up

configure时出现以下错误:
configure:error:cannot find output from lex,give up

此错误是说 缺少flex.rpm,从光盘中找到flex-%.i386.rpm,安装,重新编译php,

本人的解决办法:

configure: error: no acceptable cc found in $PATH

yum -y install gcc-c++

configure: error: cannot find output from lex; giving up flex is not installed, install flex.

yum -y install flex

configure: error: xml2-config not found. Please check your libxml2 installation.

yum -y install libxml2-devel

configure: error: Cannot find OpenSSL’s

yum -y install openssl-devel

configure: error: Please reinstall the BZip2 distribution

yum -y install bzip2-devel

configure: error: Please reinstall the libcurl distribution – easy.h should be in /include/curl/

yum -y install curl-devel

configure: error: libjpeg.(a|so) not found.

yum -y install libjpeg-devel

configure: error: libpng.(a|so) not found.

yum -y install libpng-devel

configure: error: freetype2 not found!

yum -y install freetype-devel

configure: error: Unable to locate gmp.h

yum -y install gmp-devel

configure: error: Cannot find pspell

yum -y install aspell-devel

缺哪一个,运行哪一行命令,装上后重新编辑php即可