1、所需软件:
从网上下载:libmcrypt-2.5.8.tar.gz mcrypt-2.6.8.tar.gz mhash-0.9.9.9.tar.bz2
2、安装过程
1)tar -zxvf libmcrypt-2.5.8.tar.gz
2) tar -zxvf mcrypt-2.6.8.tar.gz
3) tar -jxvf mhash-0.9.9.9.tar.bz2
环境:首先在 libmcrypt-2.5.8.tar.gz中执行
./configure
(如果有很多错误,有可能编译环境没有,需要执行下面的命令来准备编译环境
yum install gcc
yum install gcc-c++
)
make
make install
检查在/usr/local/lib 中是否有文件生成
然后再在 mhash-0.9.9.9.tar.bz2目录中执行
./configure
make
make install
然后在 mcrypt-2.6.8.tar.gz中执行
LD_LIBRARY_PATH=/usr/local/lib ./configure --with-libmcrypt-prefix=/usr/local
make
make install
下面准备生成php模块
首先上传php源码中的/ext/mcrypt目录到一个不特定的路径
检查是否有phpize,方法(whereis phpize 如果有显示路径说明已经安装,如果没有安装,需要从光盘上安装rpm -ivh php-devel包
我安装的时候还有对autoconf automake 的依赖,也是从光盘上先安装这两个包,再安装php-devel)
在刚才上传的mcrypt目录下执行
phpize
php-config
./configure --with-php-config=/usr/bin/php-config
make
(如果在结果中报错,还需要执行sed -i 's|PHP_FE_END|{NULL,NULL,NULL}|' ./mcrypt.c 之后再make)
make test 应该全通过
make install
提示Installing shared extensions: /usr/lib/php/modules/
大功告成
之后在/etc/php.d中建立一个ini文件,内容为
extension=mcrypt.so
重启httpd即可