php 安装 php7.2-mcrypt 的问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48275494/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:39:16  来源:igfitidea点击:

Issue in installing php7.2-mcrypt

phpubuntugithubmcryptpecl

提问by N?s????? ?

As I'm trying to load mcrypt extension module from PHP 7.2.X version.
So I tried to make use of PECL library that is compatible to the current version of my PHP, in order to get installed and followed this link: Installing mcrypt on PHP 7.2during installation!

因为我正在尝试从 PHP 7.2.X 版本加载 mcrypt 扩展模块。
所以我尝试使用与我的 PHP 的当前版本兼容的 PECL 库,以便安装并点击此链接: 在安装过程中在 PHP 7.2 上安装 mcrypt

These below are the result's obtained after executing certain commands on the terminal.

下面这些是在终端上执行某些命令后获得的结果。

root@YYY:/var/www/html/orocrm# apt install php-pear
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  libllvm4.0
Use 'sudo apt autoremove' to remove it.
The following NEW packages will be installed:
  php-pear
0 upgraded, 1 newly installed, 0 to remove and 14 not upgraded.
Need to get 285 kB of archives.
After this operation, 2,107 kB of additional disk space will be used.
Get:1 http://ppa.launchpad.net/ondrej/php/ubuntu xenial/main amd64 php-pear all 1:1.10.5+submodules+notgz-1+ubuntu16.04.1+deb.sury.org+1 [285 kB]
Fetched 285 kB in 1s (230 kB/s)   
Selecting previously unselected package php-pear.
(Reading database ... 215503 files and directories currently installed.)
Preparing to unpack .../php-pear_1%3a1.10.5+submodules+notgz-1+ubuntu16.04.1+deb.sury.org+1_all.deb ...
Unpacking php-pear (1:1.10.5+submodules+notgz-1+ubuntu16.04.1+deb.sury.org+1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up php-pear (1:1.10.5+submodules+notgz-1+ubuntu16.04.1+deb.sury.org+1) ...

YYY@YYY:/var/www/html/orocrm$ sudo apt-get -y install gcc make autoconf libc-dev pkg-config
[sudo] password for YYY: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'libc6-dev' instead of 'libc-dev'
gcc is already the newest version (4:5.3.1-1ubuntu1).
make is already the newest version (4.1-6).
pkg-config is already the newest version (0.29.1-0ubuntu1).
libc6-dev is already the newest version (2.23-0ubuntu9).
The following package was automatically installed and is no longer required:
  libllvm4.0
Use 'sudo apt autoremove' to remove it.
Suggested packages:
  autoconf-archive gnu-standards autoconf-doc libtool
The following NEW packages will be installed:
  autoconf automake autotools-dev libsigsegv2 m4
0 upgraded, 5 newly installed, 0 to remove and 14 not upgraded.
Need to get 1,079 kB of archives.
After this operation, 3,998 kB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 libsigsegv2 amd64 2.10-4 [14.1 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 m4 amd64 1.4.17-5 [195 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 autoconf all 2.69-9 [321 kB]
Get:4 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 autotools-dev all 20150820.1 [39.8 kB]
Get:5 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 automake all 1:1.15-4ubuntu1 [510 kB]
Fetched 1,079 kB in 2s (447 kB/s) 
Selecting previously unselected package libsigsegv2:amd64.
(Reading database ... 215198 files and directories currently installed.)
Preparing to unpack .../libsigsegv2_2.10-4_amd64.deb ...
Unpacking libsigsegv2:amd64 (2.10-4) ...
Selecting previously unselected package m4.
Preparing to unpack .../archives/m4_1.4.17-5_amd64.deb ...
Unpacking m4 (1.4.17-5) ...
Selecting previously unselected package autoconf.
Preparing to unpack .../autoconf_2.69-9_all.deb ...
Unpacking autoconf (2.69-9) ...
Selecting previously unselected package autotools-dev.
Preparing to unpack .../autotools-dev_20150820.1_all.deb ...
Unpacking autotools-dev (20150820.1) ...
Selecting previously unselected package automake.
Preparing to unpack .../automake_1%3a1.15-4ubuntu1_all.deb ...
Unpacking automake (1:1.15-4ubuntu1) ...
Processing triggers for install-info (6.1.0.dfsg.1-5) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for doc-base (0.10.7) ...
Processing 1 added doc-base file...
Setting up libsigsegv2:amd64 (2.10-4) ...
Setting up m4 (1.4.17-5) ...
Setting up autoconf (2.69-9) ...
Setting up autotools-dev (20150820.1) ...
Setting up automake (1:1.15-4ubuntu1) ...
update-alternatives: using /usr/bin/automake-1.15 to provide /usr/bin/automake (automake) in auto mode
Processing triggers for libc-bin (2.23-0ubuntu9) ...

YYY@YYY:/var/www/html/orocrm$ sudo apt-get -y install libmcrypt-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  libllvm4.0
Use 'sudo apt autoremove' to remove it.
The following NEW packages will be installed:
  libmcrypt-dev
0 upgraded, 1 newly installed, 0 to remove and 14 not upgraded.
Need to get 83.7 kB of archives.
After this operation, 438 kB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu xenial/universe amd64 libmcrypt-dev amd64 2.5.8-3.3 [83.7 kB]
Fetched 83.7 kB in 0s (105 kB/s)       
Selecting previously unselected package libmcrypt-dev.
(Reading database ... 215484 files and directories currently installed.)
Preparing to unpack .../libmcrypt-dev_2.5.8-3.3_amd64.deb ...
Unpacking libmcrypt-dev (2.5.8-3.3) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up libmcrypt-dev (2.5.8-3.3) ...

YYY@YYY:/var/www/html/orocrm$ sudo pecl7.2-sp install --nodeps mcrypt-snapshot
sudo: pecl7.2-sp: command not found

As I'm getting this type of Error as pecl7.2-sp: command not found

由于我收到此类错误,如pecl7.2-sp: command not found

From the documentation section, it had been clearly stated that it had been deprecated and no longer will be available from the security point of view — since then, from the release version of PHP 7.2.X onward's.

从文档部分,已经明确指出它已被弃用,从安全角度来看不再可用——从那时起,从 PHP 7.2.X 的发布版本开始。

But some of the project's need those dependencies, in order to carry out the required functionality as necessary. How do I need to solve the above issue?

但是一些项目需要这些依赖项,以便在必要时执行所需的功能。我需要如何解决上述问题?



UPDATE:

更新:

TL;DR:

特尔;博士:

I had a lot of response from the votes to the posted answer. The answers need to be triaged depending upon the OS Architecture level. Since I'm using the shared server for hosting, there are more than one projects residing over it & which are coded with the version of PHP 5.X.X, so I decided to downgrade to PHP 7.1.X that supports mcrypt extension by default in my Debian based OS.

从投票到发布的答案,我得到了很多回应。需要根据操作系统架构级别对答案进行分类。由于我使用共享服务器进行托管,因此有多个项目驻留在其上且使用 PHP 5.XX 版本编码,因此我决定降级到默认支持 mcrypt 扩展的 PHP 7.1.X我的基于 Debian 的操作系统。

As I already mentioned in the link while Installing mcrypt Extension on PHP 7.2, by Server Pilot community. These peoples had told a newer version of pecl-7.2 is available to install mcrypt on PHP-7.2. Unfortunately, it ended with pecl7.2-sp: command not foundfrom the executed commands which were put up. Later the website page got an update, so the commands over there doesn't match the commands that were tried while executing.

正如我在Server Pilot 社区在 PHP 7.2 上安装 mcrypt 扩展时已经在链接中提到的那样。这些人告诉过一个新版本的 pecl-7.2 可以在 PHP-7.2 上安装 mcrypt。不幸的是,它以pecl7.2-sp: command not found执行的命令结束 。后来网站页面得到更新,所以那里的命令与执行时尝试的命令不匹配。

Finally, whichever might be the solutions fit's to your OS Architecture level, Just go for it!.

最后,无论哪种解决方案适合您的操作系统架构级别,都可以去做!

OR

或者

If the below approaches didn't yield to solve the root cause.
Alternatively, you can go for PHP 7.1.X version which supports mcrypt extension by default

如果以下方法不能解决根本原因。
或者,您可以选择默认支持 mcrypt 扩展的 PHP 7.1.X 版本

回答by Praneeth Nidarshan

I followed below steps to install mcryptfor PHP7.2 using PECL.

我按照以下步骤使用PECL为 PHP7.2安装mcrypt

  1. Install PECL
  1. 安装 PECL

apt-get install php-pecl

apt-get 安装 php-pecl

  1. Before installing MCRYPT you must install libmcrypt
  1. 在安装 MCRYPT 之前,您必须安装 libmcrypt

apt-get install libmcrypt-dev libreadline-dev

apt-get install libmcrypt-dev libreadline-dev

  1. Install MCRYPT 1.0.1using PECL
  1. 使用 PECL安装MCRYPT 1.0.1

pecl install mcrypt-1.0.1

pecl 安装 mcrypt-1.0.1

  1. After the successful installation
  1. 安装成功后

You should add "extension=mcrypt.so" to php.ini

您应该将“ extension=mcrypt.so”添加到 php.ini

Please comment below if you need any assistance. :-)

如果您需要任何帮助,请在下面发表评论。:-)

IMPORTANT !

According to php.netreference many (all) mcrypt functions have been DEPRECATEDas of PHP 7.1.0. Relying on this function is highly discouraged.

重要的 !

根据php.net参考,从 PHP 7.1.0开始,许多(所有)mcrypt 函数已被弃用。强烈建议不要依赖此功能。

回答by Shahid Neermunda

Mcrypt PECL extenstion

Mcrypt PECL 扩展

 sudo apt-get -y install gcc make autoconf libc-dev pkg-config
 sudo apt-get -y install libmcrypt-dev
 sudo pecl install mcrypt-1.0.1

When you are shown the prompt

当您看到提示时

 libmcrypt prefix? [autodetect] :

Press [Enter] to autodetect.

按 [Enter] 自动检测。

After success installing mcrypt trought pecl, you should add mcrypt.so extension to php.ini.

成功安装 mcrypt trought pecl 后,您应该将 mcrypt.so 扩展名添加到 php.ini。

The output will look like this:

输出将如下所示:

...
Build process completed successfully
Installing '/usr/lib/php/20170718/mcrypt.so'    ---->   this is our path to mcrypt extension lib
install ok: channel://pecl.php.net/mcrypt-1.0.1
configuration option "php_ini" is not set to php.ini location
You should add "extension=mcrypt.so" to php.ini

Grab installing path and add to cli and apache2 php.ini configuration.

获取安装路径并添加到 cli 和 apache2 php.ini 配置中。

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"

Verify that the extension was installed

验证是否安装了扩展

Run command:

运行命令:

php -i | grep "mcrypt"

The output will look like this:

输出将如下所示:

/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, 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

回答by SimionZ

@praneeth-nidarshan has covered mostly all the steps, except some:

@praneeth-nidarshan 几乎涵盖了所有步骤,除了一些:

  • Check if you have pear installed (or install):
  • 检查您是否安装了(或安装)梨:

$ sudo apt-get install php-pear

$ sudo apt-get install php-pear

  • Install, if isn't already installed, php7.2-dev, in order to avoid the error:
  • 安装,如果还没有安装,php7.2-dev,以避免错误:

sh: phpize: not found

ERROR: `phpize' failed

sh:phpize:未找到

错误:`phpize' 失败

$ sudo apt-get install php7.2-dev

$ sudo apt-get install php7.2-dev

  • Install mcrypt using pecl:
  • 使用 pecl 安装 mcrypt:

$ sudo pecl install mcrypt-1.0.1

$ sudo pecl install mcrypt-1.0.1

  • Add the extention extension=mcrypt.soto your php.ini configuration file; if you don't know where it is, search with:
  • 将扩展添加extension=mcrypt.so到您的 php.ini 配置文件中;如果您不知道它在哪里,请搜索:

$ sudo php -i | grep 'Configuration File'

$ sudo php -i | grep 'Configuration File'

回答by hk'

sudo apt-get install php-pear php7.x-dev

x is your php version like 7.2 the php7.2-dev

x 是你的 php 版本,比如 7.2 php7.2-dev

apt-get install libmcrypt-dev libreadline-dev
pecl install mcrypt-1.0.1 

then add "extension=mcrypt.so" in "/etc/php/7.2/apache2/php.ini"

然后在“/etc/php/7.2/apache2/php.ini”中添加“ extension=mcrypt.so

here php.ini is depends on your php installatio and apache used php version.

这里的 php.ini 取决于你的 php installatio 和 apache 使用的 php 版本。

回答by Vadi

As an alternative, you can install 7.1 version of mcryptand create a symbolic link to it:

作为替代方案,您可以安装 7.1 版本mcrypt并创建指向它的符号链接:

Install php7.1-mcrypt:

安装 php7.1-mcrypt:

sudo apt install php7.1-mcrypt

Create a symbolic link:

创建符号链接:

sudo ln -s /etc/php/7.1/mods-available/mcrypt.ini /etc/php/7.2/mods-available

After enabling mcryptby sudo phpenmod mcrypt, it gets available.

通过启用mcryptsudo phpenmod mcrypt,它变得可用。