CentOS下php安装mcrypt扩展

转载 李亚飞 大佬的文章:https://www.lyafei.com/

安装mcrypt

先确认你的php和pecl版本
[root@lyafei ~]# php -v
PHP 7.2.26 (cli) (built: Dec 31 2019 17:01:19) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
[root@lyafei ~]# pecl version
PEAR Version: 1.10.10
PHP Version: 7.2.26
Zend Engine Version: 3.2.0
确认你的linux有没有安装mcrypt库
[root@lyafei ~]# yum list installed | grep mcrypt
libmcrypt.x86_64                      2.5.8-13.el7                   @epel      
libmcrypt-devel.x86_64                2.5.8-13.el7                   @epel      
mcrypt.x86_64                         2.6.8-11.el7                   @epel      

以上显示已经安装过,若没有则按以下两种方式安装:

(方法一)yum命令安装

yum install libmcrypt libmcrypt-devel mcrypt mhash

执行后会显示即将安装的相关库,你可以根据你的 linux 限定 x86_64 或者 i386,如 yum install libmcrypt.x86_64(如果 yum 命令无法连接仓库,请检查你的 /etc/yum.repos.d/ 里的文件正确性,以及你的 /etc/host 是不是可达里面的域名)

确定安装,最后显示

Installed:
  libmcrypt.x86_64 0:2.5.8-13.el7.centos
  libmcrypt-devel.x86_64 0:2.5.8-13.el7.centos
  mcrypt.x86_64 0:2.6.8-11.el7
  mhash.x86_64 0:0.9.9-1.el7.rf

Complete!
(方法二)源码编译安装

http://www.sourceforge.net 下载 libmcrypt,mhash,mcrypt安装包

先安装libmcrypt

tar -zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make
make install

libmcript 默认安装在 /usr/local

安装mhash

tar -zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure
make
make install

安装mcrypt

tar -zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
LD_LIBRARY_PATH=/usr/local/lib ./configure
make
make install
安装php的mcrypt扩展(动态加载编译)

下载 php 的 mcrypt 扩展或者直接下载 php 的完整安装包
http://cn.php.net/releases/ 网页下找到自己服务器的 php 版本,下载后 tar 解压(本人的是 php 7.2.26)

因为 mcrypt 扩展从 php 7.1.0 开始废弃;自 php 7.2.0 起,会移到 pecl

php扩展官网 下载 mcrypt 包

wget  http://pecl.php.net/get/mcrypt-1.0.1.tgz
tar xf mcrypt-1.0.1.tgz
cd mcrypt-1.0.1
[root@lyafei mcrypt-1.0.1]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version:         20170718
Zend Module Api No:      20170718
Zend Extension Api No:   320170718
[root@lyafei mcrypt-1.0.1]# ./configure --with-php-config=/usr/local/php/bin/php-    config  && make && make install
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
......
Build complete.

在 php.ini 加上扩展即可

extension = mcrypt.so

重启 php-fpm

service php-fpm restart

这个时候查看 phpinfo 就可以看到 mcrypt 模块加载了

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值