如何在 php 7.2.x 中安装 mcrypt?

如何在 php 7.2.x 中安装 mcrypt?

我知道有类似的问题,但都没有帮助我。我尝试使用这些命令安装 mcrypt

sudo apt install php-dev libmcrypt-dev php-pear
sudo pecl channel-update pecl.php.net
sudo pecl install mcrypt-1.0.1

这给了我这个错误

downloading mcrypt-1.0.1.tgz ...
Starting to download mcrypt-1.0.1.tgz (33,782 bytes)
.........done: 33,782 bytes
6 source files, building
running: phpize
sh: 1: phpize: not found
ERROR: `phpize' failed

我非常需要这个来加密我的 cookie。任何帮助我都会很感激。

答案1

很奇怪,但我想我遵循了错误的教程。这些命令帮助我修复了它

sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install php7.2-dev
sudo apt-get -y install libmcrypt-dev

其次是

sudo bash -c "echo extension=/usr/lib/php/20170718/mcrypt.so > /etc/php/7.2/cli/conf.d/mcrypt.ini"
sudo bash -c "echo extension=/usr/lib/php/20170718/mcrypt.so > /etc/php/7.2/apache2/conf.d/mcrypt.ini"

之后

php -i | grep mcrypt

给出

/etc/php/7.2/cli/conf.d/mcrypt.ini
Registered Stream Filters => zlib.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, bzip2.*, convert.iconv.*, mcrypt.*, mdecrypt.*
mcrypt
mcrypt support => enabled
mcrypt_filter support => enabled
mcrypt.algorithms_dir => no value => no value
mcrypt.modes_dir => no value => no value

我希望安装成功。

答案2

根据https://pecl.php.net/package/mcrypt您尝试安装的版本 1.0.1 仅支持最高 PHP 7.3.0。

Release 1.0.1:
==================

Dependencies:
    PHP Version: PHP version 7.3.0 or older
    PHP Version: PHP 7.2.0 or newer
    PEAR Package: PEAR 1.4.0 or newer

相关内容