(以下步骤均为本人实际操作,可能与你的安装方法有所区别,但我会尽量排除疑惑)
大致步骤(1)安装mcrypt,(2)安装php对mcrypt的扩展,(3)重启apache
[root@test-206 ~]# yum list installed|grep mcryptlibmcrypt.x86_64 2.5.8-4.el5.centos installedlibmcrypt-devel.x86_64 2.5.8-4.el5.centos installedmcrypt.x86_64 2.6.8-1.el5 installed
以上显示已经安装过,若没有,则按以下两种方式安装
yum install libmcrypt libmcrypt-devel mcrypt mhash
Dependencies Resolved================================================================================ Package Arch Version Repository Size================================================================================Installing: libmcrypt i386 2.5.7-5.el5 epel 124 k libmcrypt x86_64 2.5.8-4.el5.centos extras 105 k libmcrypt-devel i386 2.5.7-5.el5 epel 103 k libmcrypt-devel x86_64 2.5.8-4.el5.centos extras 10 k mcrypt x86_64 2.6.8-1.el5 epel 88 k mhash i386 0.9.2-6.el5 epel 141 k mhash x86_64 0.9.9-1.el5.rf rpmforge 161 kTransaction Summary================================================================================Install 7 Package(s)Upgrade 0 Package(s)Total download size: 731 kIs this ok [y/N]:
Installed: libmcrypt.x86_64 0:2.5.8-4.el5.centos libmcrypt-devel.x86_64 0:2.5.8-4.el5.centos mcrypt.x86_64 0:2.6.8-1.el5 mhash.x86_64 0:0.9.9-1.el5.rfComplete!
libmcrypt(libmcrypt-2.5.8.tar.gz ):
mcrypt(mcrypt-2.6.8.tar.gz ):
mhash(mhash-0.9.9.9.tar.gz ):
#tar -zxvf libmcrypt-2.5.8.tar.gz#cd libmcrypt-2.5.8#./configure#make#make install 说明:libmcript默认安装在/usr/local
#tar -zxvf mhash-0.9.9.9.tar.gz#cd mhash-0.9.9.9#./configure#make#make install
#tar -zxvf mcrypt-2.6.8.tar.gz#cd mcrypt-2.6.8#LD_LIBRARY_PATH=/usr/local/lib ./configure#make#make install
(2)、安装php的mcrypt扩展(动态加载编译)
下载php下的mcrypt扩展或者直接下载php的完整安装包
http://cn.php.net/releases/ 网页下找到自己服务器的php版本,下载后tar解压(本人的是php5.3.3)
进入ext/mcrypt文件夹
[root@*_* 14:45 ~]# cd php-5.3.3/ext/mcrypt/
[root@*_* 14:48 mcrypt]# whereis phpize //为了确定phpize存在phpize: /usr/bin/phpize /usr/share/man/man1/phpize.1.gz[root@*_* 14:48 mcrypt]# phpizeConfiguring for:PHP Api Version: 20090626Zend Module Api No: 20090626Zend Extension Api No: 220090626
执行完后,会发现当前目录下多了一些configure文件,最后执行php-config命令就基本完成了
执行以下命令,确保你的/usr/bin/php-config是存在的
[root@*_* 15:02 mcrypt]# whereis php-configphp-config: /usr/bin/php-config /usr/share/man/man1/php-config.1.gz[root@*_* 15:02 mcrypt]# ./configure --with-php-config=/usr/bin/php-config
configure: error: no acceptable C compiler found in $PATH
[root@*_* 15:06 mcrypt]# make && make install
Installing shared extensions: /usr/lib64/php/modules/
顺便检查下/usr/lib64/php/modules/里的mrcypt.so扩展是否已经创建成功
然后的事就简单了,给你的php.ini添加一条extension=mcrypt.so
[root@*_* 15:09 mcrypt]# cd /etc/php.d
[root@*_* 15:17 php.d]# echo 'extension=mcrypt.so' > mcrypt.ini