The Encrypt library requires the Mcrypt extension

淺唱寂寞╮ 提交于 2020-01-12 19:09:13

问题


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

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

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


回答1:


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




回答2:


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

Simply replace encrypt with encryption in autoload.php

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

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



回答3:


On Linux where PHP 5.6 or less...

apt-get install php5-mcrypt




回答4:


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

Mcrypt PECL extenstion

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:

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



回答5:


Open php.ini

search for ;extension=php_mcrypt.dll

then remove ; infront of it to uncomment it.

save the php.ini file




回答6:


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

<?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:

  • Find php.ini (main php configuration file)

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

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




回答7:


For Windows users

Autoload.php file will be as follows

$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....

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



来源:https://stackoverflow.com/questions/50541560/the-encrypt-library-requires-the-mcrypt-extension

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!