服务器LINUX下PHP安装MCRYPT扩展

蜗牛vpsvps教程2021-04-173350

说明:

操作系统:CentOS 5.x 64位

已安装php版本:php-5.4.4

已安装php路径:/usr/local/php

实现目的:

在不影响网站访问的情况下,重新编译php,增加对mcrypt扩展的支持

具体操作:

一、下载软件包

1、下载php(版本要与系统安装的一致)

http://museum.php.net/php5/php-5.4.4.tar.gz

2、下载libmcrypt(安装mcrypt需要此软件包)

http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz

3、下载mhash(安装mcrypt需要此软件包)

https://acelnmp.googlecode.com/files/mhash-0.9.9.9.tar.gz

4、下载mcrypt

https://lcmp.googlecode.com/files/mcrypt-2.6.8.tar.gz

以上软件包下载之后,上传到/usr/local/src目录

二、安装软件包

1、安装libmcrypt

cd /usr/local/src  #进入软件包存放目录

tar zxvf libmcrypt-2.5.8.tar.gz  #解压

cd libmcrypt-2.5.8  #进入安装目录

./configure  #配置

make  #编译

make install  #安装

2、安装mhash

cd /usr/local/src

tar zxvf mhash-0.9.9.9.tar.gz

cd mhash-0.9.9.9

./configure

make

make install

3、安装mcrypt

cd /usr/local/src

tar zxvf mcrypt-2.6.8.tar.gz

cd mcrypt-2.6.8

ln -s   /usr/local/bin/libmcrypt_config   /usr/bin/libmcrypt_config  #添加软连接

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH  #添加环境变量

./configure

make

make install

三、重新编译php

1、查看系统之前安装的php编译参数

系统运维  www.osyunwei.com  温馨提醒:qihang01原创内容 版权所有,转载请注明出处及原文链接

/usr/local/php/bin/php -i |grep configure  #查看php编译参数,记录下编译参数,后面会用到

2、安装php

cd /usr/local/src

tar zxvf php-5.4.4.tar.gz

cd php-5.4.4

'./configure' '--prefix=/usr/local/php' '--enable-mbstring=all' '--with-config-file-path=/usr/local/php/etc' '--with-zlib' '--with-mysql=/usr/local/mysql-5.1.38/' '--with-gd' '--with-mysqli=/usr/local/mysql-5.1.38/bin/mysql_config' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--enable-fpm' '--enable-soap' '--with-freetype-dir=/usr/lib64' '--with-iconv=/usr/local' '--with-curl' '--with-mcrypt'

#在之前的编译参数后面增加'--with-mcrypt' 回车

make  #编译

make install  #安装

/usr/local/src/php-5.4.4/sapi/fpm/init.d.php-fpm  reload  #重新加载php-fpm

四、测试mcrypt扩展是否已安装成功

在网站目录下新建一个info.php测试页面,写上下面代码,保存


phpinfo();

?>

在浏览器中打开info.php 会看到如下的信息

 

 

说明mcrypt扩展已经安装成功

至此,Linux下php安装mcrypt扩展完成。


评论

有免费节点资源,我们会通知你!加入纸飞机订阅群

×
天气预报查看日历分享网页手机扫码留言评论电报频道链接