php 加密库需要 Mcrypt 扩展

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/50541560/
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:50:08  来源:igfitidea点击:

The Encrypt library requires the Mcrypt extension

phpcodeigniter

提问by Rahul Kumar Singh

I have a PHP application written using the Codeigniter framework. When I am trying to run this application on Windows Machine then I am getting below error:

我有一个使用 Codeigniter 框架编写的 PHP 应用程序。当我尝试在 Windows 机器上运行此应用程序时,出现以下错误:

An Error Was Encountered
The Encrypt library requires the Mcrypt extension.

遇到错误
加密库需要 Mcrypt 扩展。

This same application working fine on some random Windows Machine having the same configuration. I have tried on 5 different windows 10 machines and got this error on 3 Machine and worked fine on 2 machines. Here I have used the same installer to install XAMPP on all the machines and the same code, but still don't know how to make it run smoothly. I have tried almost all the suggestions available online like to make a change in php.ini but no luck so far.

这个相同的应用程序在一些具有相同配置的随机 Windows 机器上运行良好。我在 5 台不同的 Windows 10 机器上尝试过,在 3 台机器上出现了这个错误,在 2 台机器上运行良好。这里我用同一个安装程序在所有机器上安装了XAMPP,代码都一样,但是还是不知道怎么才能顺利运行。我已经尝试了几乎所有在线可用的建议,比如在 php.ini 中进行更改,但到目前为止还没有运气。

回答by Pushpendra Kumar

(FOR CI USERS only) If you are switched from CI2 XAMPP(php5) to XAMPP(php7) then, paste encrypt.phpin CI->system->libraries folder, after this it should be fine !

(仅适用于CI用户)如果您是从CI2 XAMPP(PHP5)切换到XAMPP(PHP7)然后,粘贴encrypt.php在CI->系统- >库文件夹,在此之后应该罚款!

回答by Abhishek Soni

For the future comers, I have face this problem too. It is usually issue with php 7.2.

对于未来的人,我也面临这个问题。它通常是 php 7.2 的问题。

Simply replace encryptwith encryptionin autoload.php

只需在 autoload.php 中替换encryptencryption

$autoload['libraries'] = array('database', 'email', 'session', 'encrypt', 'pagination');

$autoload['libraries'] = array('database', 'email', 'session', '**encryption**', 'pagination');

回答by Anatoliy R

To codeigniterdevelopers: some CIreleases do not have encryptlisted in autoload

对于codeigniter开发人员:一些CI版本在自动加载中没有列出加密

$autoload['libraries'] = array();

Instead, they are loaded under CI_Controllerderived controllers.

相反,它们在CI_Controller派生控制器下加载。

Search for

搜索

$this->load->library('encrypt');

and replace with:

并替换为:

$this->load->library('encryption');

回答by Bira

On Linux where PHP 5.6 or less...

在 PHP 5.6 或更低版本的 Linux 上...

apt-get install php5-mcrypt

apt-get install php5-mcrypt

回答by Nagababu m

For Windows users

对于 Windows 用户

Autoload.php file will be as follows

Autoload.php 文件如下

$autoload['libraries'] = array('database', 'session', 'form_validation', 'encrypt', 'template', 'finediff', 'parser');

$autoload['libraries'] = array('database', 'session', 'form_validation', 'encrypt', 'template', 'finediff', 'parser');

From the above remove encryption like below, after that restart apache services then it will works....

从上面删除像下面这样的加密,然后重新启动 apache 服务,然后它就可以工作了....

$autoload['libraries'] = array('database', 'session', 'form_validation', 'template', 'finediff', 'parser');

$autoload['libraries'] = array('database', 'session', 'form_validation', 'template', 'finediff', 'parser');

回答by pspatel

Run the following code to check if the mccrypt is enabled in your PHP Settings.

运行以下代码以检查您的 PHP 设置中是否启用了 mccrypt。

<?php phpinfo(); ?>

By default, it is enabled on some server so that's why it is working on the random machine.

默认情况下,它在某些服务器上启用,这就是它在随机机器上工作的原因。

The quickest method to enable php-mcrypt on windows server – all you need to do is:

在 Windows 服务器上启用 php-mcrypt 的最快方法 - 您需要做的就是:

  • Find php.ini (main php configuration file)

  • Open and search for;extension=php_mcrypt.dll )

  • Uncomment/remove “;” and save the php.ini

  • 找到php.ini(主要的php配置文件)

  • 打开并搜索;extension=php_mcrypt.dll )

  • 取消注释/删除“;” 并保存 php.ini

回答by spoofie

Open php.ini

打开 php.ini

search for ;extension=php_mcrypt.dll

搜索 ;extension=php_mcrypt.dll

then remove ;infront of it to uncomment it.

然后删除; 在它面前取消注释。

save the php.ini file

保存 php.ini 文件

回答by Shashank Saxena

I was using PHP 7.2.xx version of php and followed the following steps:

我使用的是 PHP 7.2.xx 版本的 php 并遵循以下步骤:

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

Update the ini file with these commands:

使用以下命令更新 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"

Verifying the installation:

验证安装:

php7.2-sp -i | grep mcrypt