Как установить MCrypt для PHP 7.x
Расширение MCrypt предназначено для шифрования/дешифрования данных. Оно было признано устаревшим и в итоге, начиная с версии PHP 7.2 его убрали из ядра php. Однако, могут возникнуть ситуации, когда это расширение может понадобится, когда, например, вы работаете с какой-то устаревшей cms или просто старой программой и нет времени или желания переделывать программу.
Расширение MCrypt было перенесено в PECL по адресу https://pecl.php.net/package/mcrypt. На момент написания статьи последняя версия 1.0.3, которая поддерживает PHP 7.2, PHP 7.3 и PHP 7.4, а так же обещает поддержку PHP 8, который пока еще не вышел.
Как установить MCrypt для PHP 7.2, 7.3, 7.4 для Linux
Необходимо выполнить обновление репозитария и затем установить расширение:
После установки найдите куда установился файл mcrypt.so. Скорее всего это /usr/lib/php/modules/mcrypt.so или /usr/lib64/php/modules/mcrypt.so
Затем нужно найти php.ini. Не могу указать точный путь, т.к. на разных системах это могут быть абсолютно разные места, например, /etc/php.ini, либо /etc/php/7.2/cli/php.ini или /opt/php72/etc и др. Так же, php.ini может быть в папке пользователя.
В php.ini найдите где добавляются другие расширения (строки начинающиеся «extension=»), либо просто в конце файла, каким-нибудь редактором добавьте строку:
где вместо path_to_mcrypt напишите свой путь, который находили ранее.
Как установить MCrypt для PHP 7.2, 7.3, 7.4 для Windows
Скачайте архив расширения со страницы PECL https://pecl.php.net/package/mcrypt/1.0.3/windows для нужной версии PHP. Если не уверены, какая именно версия Thread Safe (TS) x86, Non Thread Safe (NTS) x86 или тоже x64 нужна, скачайте все четыре версии. Потом просто попробуете каждую из них и какая заработает, ту и оставите.
В скачанном архиве вам нужен файл php_mcrypt.dll — его нужно распаковать в папку, где установлен ваш PHP в подкаталог ext, где находятся и все другие расширения.
В php.ini найдите где добавляются другие расширения (строки начинающиеся «extension=»), либо в конце файла, добавьте строку:
где вместо path_to_mcrypt напишите путь, куда распаковали dll-файл.
Вместо полного пути к библиотеки, можно так же в php.ini написать:
Проверить установку можно просто на одном из сайтов своего сервера выполнить php-код: phpinfo();. При этом, должна появиться секция mcrypt:
На этом установка MCrypt для PHP 7.2, 7.3, 7.4 завершена.
Since PHP 7.2 the mcrypt extension doesn’t exists anymore #278
Comments
Copy link Quote reply
ruben-haegeman commented Dec 13, 2017 •
Since PHP 7.2 the mcrypt extension isn’t released anymore since it was deprecated for 7.1
The composer.json file does allow it to be installed with PHP 7.2. An upgrade should be made to the library to move away from mcrypt.
pitbulk commented Dec 13, 2017
nishanth6 commented Apr 6, 2018
Issue Solved when installing php7.2-mcrypt
I was also facing the same issue. Check this link https://stackoverflow.com/q/48275494/7713811 to get the right solution for installing it in PHP
nimaamiri92 commented Oct 1, 2018
Any solution for windows servers or Xampp?
ghost commented May 13, 2019 •
I want install mcrypt on windows xamp 7.2 server
please help me
how to install mcrypt php extension in xampp windows
khadev commented Mar 10, 2020 •
1-First, you should download the suitable version for your system from here:
https://pecl.php.net/package/mcrypt/1.0.3/windows
2-Later, you should copy php_mcrypt.dll under ../xampp/php/ext/
3-you should enable extension like extension=mcrypt from xampp/php/php.ini
personly I modified the php.ini file and i add this lines :
of course, these two lines have the 3 dll file saved on ../xampp/php/ext/ as :
Kirti003Shukla commented Apr 20, 2020
1-First, you should download the suitable version for your system from here:
https://pecl.php.net/package/mcrypt/1.0.3/windows
2-Later, you should copy php_mcrypt.dll under ../xampp/php/ext/
3-you should enable extension like extension=mcrypt from xampp/php/php.ini
personly I modified the php.ini file and i add this lines :
of course, these two lines have the 3 dll file saved on ../xampp/php/ext/ as :
I am not able to resolve my problem, so posting over closed issue. I followed the same procedure but now I am receiving an error as whoops something went wrong. Please let me know how to resolve the issue.
php 7.3.16
installed this
php_mcrypt-1.0.3-7.3-ts-vc15-x64.zip
updated php.ini as
extension=mcrypt
xampp v3.2.4
mohamadRaafatKamel commented May 3, 2020
1-First, you should download the suitable version for your system from here:
https://pecl.php.net/package/mcrypt/1.0.3/windows
2-Later, you should copy php_mcrypt.dll under ../xampp/php/ext/
3-you should enable extension like extension=mcrypt from xampp/php/php.ini
personly I modified the php.ini file and i add this lines :
of course, these two lines have the 3 dll file saved on ../xampp/php/ext/ as :
jain-priyal commented May 4, 2020
hi
1-First, you should download the suitable version for your system from here:
https://pecl.php.net/package/mcrypt/1.0.3/windows
2-Later, you should copy php_mcrypt.dll under ../xampp/php/ext/
3-you should enable extension like extension=mcrypt from xampp/php/php.ini
personly I modified the php.ini file and i add this lines :
extension=imap
extension=mcrypt
of course, these two lines have the 3 dll file saved on ../xampp/php/ext/ as :
php_imap.dll
php_mcrypt.dll
I am not able to resolve my problem, so posting over closed issue. I followed the same procedure but now I am receiving an error as whoops something went wrong. Please let me know how to resolve the issue.
php 7.3.16
installed this
php_mcrypt-1.0.3-7.3-ts-vc15-x64.zip
updated php.ini as
extension=mcrypt
xampp v3.2.4
Facing same issue. How did you resolve this?
php 7.3.12
used php_mcrypt-1.0.3-7.3-ts-vc15-x64.zip
updated php.ini with
extension=php_mcrypt.dll
wamp 3.2.0
restarted all wamp services
php_mcrypt is showing in the extensions list. But when I try to run ‘php artisan migrate’ I still get
error saying «Mcrypt PHP extension required.»
brymacha commented May 22, 2020
you should download the suitable version for your system from here:
https://pecl.php.net/package/mcrypt/1.0.3/windows
Extract and paste php_mcrypt.dll in /xampp/php/ext/ folder
Edit php.ini file in /xampp/php/ by adding the line:
extension=php_mcrypt.dll
Restart apache, its done.
ahtshambhatti commented Jun 24, 2020
1-First, you should download the suitable version for your system from here:
https://pecl.php.net/package/mcrypt/1.0.3/windows
2-Later, you should copy php_mcrypt.dll under ../xampp/php/ext/
3-you should enable extension like extension=mcrypt from xampp/php/php.ini
personly I modified the php.ini file and i add this lines :
of course, these two lines have the 3 dll file saved on ../xampp/php/ext/ as :
arzzen / install-php7.2-mcrypt.sh
# # |
# # How to install mcrypt in php7.2 / php7.3 |
# # Linux / MacOS / OSX |
# # |
# # https://lukasmestan.com/install-mcrypt-extension-in-php7-2/ |
# |
# Check version php and pecl |
# |
php -v # if default php is not 7.2 then use /usr/bin/php7.2 instead php |
pecl version |
sudo apt-get install php-pear |
sudo apt-get install php7.2-dev |
# |
# Install mcrypt extension |
# see http://pecl.php.net/package-info.php?package=mcrypt&version=1.0.1 |
# |
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. |
# |
# After success installing mcrypt trought pecl, you should add mcrypt.so extension to 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 |
# |
# example: |
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 « |
# check that the extension was installed with this 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 |
# final step |
sudo service apache2 restart |
This comment has been minimized.
Copy link Quote reply
vermaysha commented Apr 15, 2018
This comment has been minimized.
Copy link Quote reply
khoi-thinh commented Apr 18, 2018
How to do this with Amazon Linux 1?
This comment has been minimized.
Copy link Quote reply
didinkaj commented Apr 23, 2018
how about windows version
This comment has been minimized.
Copy link Quote reply
footniko commented Apr 25, 2018
For those, who faced with ERROR: ‘phpize’ failed issue, you may install it with sudo sudo apt-get install php7.2-dev command.
This comment has been minimized.
Copy link Quote reply
9073241516 commented Apr 28, 2018
is there a ‘mcrypt’ for PHP 7.2 on Windows?
This comment has been minimized.
Copy link Quote reply
9073241516 commented Apr 28, 2018 •
I found that the lastest version of PHP which cames with these Dll´s (‘libmcrypt.dll’ and ‘/ext/php_mcrypt.dll’) is php-5.2.9-Win32-VC6-x86.zip
This comment has been minimized.
Copy link Quote reply
9073241516 commented Apr 28, 2018
I tried to copy these files and also call it on the ‘C:\PROGRAM FILES\PHP\V7.2\PHP.INI’ as the article ‘https://www.myoddweb.com/2010/11/18/install-mcrypt-for-php-on-windows/’ but no sucess.
This comment has been minimized.
Copy link Quote reply
9073241516 commented Apr 28, 2018
I found some ‘tricks’ to put that module work on Linux PHP v7.2:
This comment has been minimized.
Copy link Quote reply
9073241516 commented Apr 28, 2018
Another trick but for php 5.8:
This comment has been minimized.
Copy link Quote reply
yatskanich commented Apr 29, 2018
This comment has been minimized.
Copy link Quote reply
juanesrios commented May 1, 2018
add:
sudo apt-get install php7.2-dev
This comment has been minimized.
Copy link Quote reply
luis02lopez commented May 27, 2018 •
Thanks! One questions: What if we are using Ngnix instead of Apache in this step: sudo bash -c «echo extension=/usr/lib/php/20170718/mcrypt.so > /etc/php/7.2/apache2/conf.d/mcrypt.ini»
This comment has been minimized.
Copy link Quote reply
rahmanfrictionless commented Jun 4, 2018
This comment has been minimized.
Copy link Quote reply
computerfever commented Jun 8, 2018
how to install Php mcrypt extension in php 7.2.4 on windows xamp
This comment has been minimized.
Copy link Quote reply
codecreate-dev commented Jun 17, 2018
Thanks. worked perfectly Ubuntu 18.04.
This comment has been minimized.
Copy link Quote reply
Vannoch91 commented Jun 20, 2018
Dear all, anyone can show me How to fix on Mcrypt php extension required on PHP 7.2?
This comment has been minimized.
Copy link Quote reply
1988gadocansey commented Jun 25, 2018
This comment has been minimized.
Copy link Quote reply
yogirzlsinatrya commented Jul 12, 2018
there is no solution for PHP 7.2 in XAMPP windows ?
This comment has been minimized.
Copy link Quote reply
nagarajsajjan commented Jul 12, 2018
It Worked for me, Thank you
Final step — sudo service apache2 restart
This comment has been minimized.
Copy link Quote reply
fipso commented Jul 25, 2018
This comment has been minimized.
Copy link Quote reply
battoni commented Aug 8, 2018
Worked like a charm!
Thanks man!
This comment has been minimized.
Copy link Quote reply
sirdavincci commented Aug 21, 2018
Thanks bro!. Worked awesome.
This comment has been minimized.
Copy link Quote reply
ThakurPradeep commented Aug 28, 2018
Thanks, It’s working fine.
This comment has been minimized.
Copy link Quote reply
Dhayllin commented Aug 30, 2018
This comment has been minimized.
Copy link Quote reply
XIAOXIAOSIYU commented Sep 18, 2018
Still wondering if there is a successful version for PHP7.2 on WINDOWS, thanks!
This comment has been minimized.
Copy link Quote reply
nimaamiri92 commented Oct 1, 2018
Any solution windows servers?
This comment has been minimized.
Copy link Quote reply
suebphatt commented Oct 17, 2018
This comment has been minimized.
Copy link Quote reply
reganto commented Oct 21, 2018
Thank you .
Its works 🙂
This comment has been minimized.
Copy link Quote reply
Chibuikekenneth commented Nov 30, 2018
This comment has been minimized.
Copy link Quote reply
4nd12i commented Jan 28, 2019
Thank’s it solved my problem.
This comment has been minimized.
Copy link Quote reply
akamomer commented Feb 3, 2019
Worked for me also many thanks 👍
This comment has been minimized.
Copy link Quote reply
ShahzadAhmed commented Feb 19, 2019
After trying to many things. I just got rid of this shit by installing both version on my computer.
First I installed php 7.1.19 version.
Secondly I installed php 7.2.15 version
Now I am working perfectly with my project.
This comment has been minimized.
Copy link Quote reply
manojkumar-iksula commented Mar 28, 2019
This comment has been minimized.
Copy link Quote reply
MrPetovan commented Apr 18, 2019
Thanks! On my Devuan (Debian minus systemd) server, the only change I made was instead of
This comment has been minimized.
Copy link Quote reply
elfeffe commented Jun 18, 2019
For PHP 7.3 this is
sudo pecl install mcrypt-1.0.2
This comment has been minimized.
Copy link Quote reply
partuner commented Jul 25, 2019
thank you very much , working perfect on ubuntu 18.04.2
This comment has been minimized.
Copy link Quote reply
jalmoreno commented Aug 1, 2019
This comment has been minimized.
Copy link Quote reply
yudanilam commented Aug 8, 2019
This comment has been minimized.
Copy link Quote reply
kevinski303 commented Aug 14, 2019 •
did you get it work on php 7.3 only?
i get phpize failed which forces me to install php 7.2 regarding this manual
This comment has been minimized.
Copy link Quote reply
Resmedia commented Aug 18, 2019
For PHP 7.3 this is
sudo pecl install mcrypt-1.0.2
This comment has been minimized.
Copy link Quote reply
dave-lw commented Aug 29, 2019 •
thanks, worked on my windows linux subsystem,
php 7.2 i believe on ubuntu.
This comment has been minimized.
Copy link Quote reply
fedorovvldmr commented Dec 20, 2019
It didn’t work for me
PHP Warning: PHP Startup: mcrypt: Unable to initialize module
Module compiled with module API=20190902
PHP compiled with module API=20170718
These options need to match
in Unknown on line 0
This comment has been minimized.
Copy link Quote reply
dave-lw commented Dec 21, 2019 •
PHP Warning: PHP Startup: mcrypt: Unable to initialize module
Module compiled with module API=20190902
PHP compiled with module API=20170718
These options need to match
in Unknown on line 0
you have multiple php versions installed, i see you are having trouble and running any commands you googled. I had a coworker who did the same thing. He figured out how to make his cli and normal php the same version and then got this working. please follow my next post
This comment has been minimized.
Copy link Quote reply
dave-lw commented Dec 21, 2019 •
when you get phpize error
Q: I see error message: ERROR: ‘phpize’ failed
A: install php7.2-dev with apt-get install php7.2-dev
This comment has been minimized.
Copy link Quote reply
fedorovvldmr commented Dec 21, 2019
@dave-lw, i installed it form source code (gist)
This comment has been minimized.
Copy link Quote reply
dave-lw commented Dec 21, 2019
yeah the problem is with your php though, you have several versions installed and it is causing problems. I gave you the solution.
This comment has been minimized.
Copy link Quote reply
HenkPoley commented Jan 22, 2020 •
For Xampp you can look for the DLL links here: https://pecl.php.net/package/mcrypt
I dropped the DLL in C:\xampp_7.3.12\php\ext\ , and added the line extension=php_mcrypt.dll to php.ini
Reminder: you are not supposed to use mcrypt in production.
This comment has been minimized.
Copy link Quote reply
abenitesvil commented Apr 21, 2020
This comment has been minimized.
Copy link Quote reply
afoysal commented Jul 15, 2020
For PHP 7.3 this is
sudo pecl install mcrypt-1.0.2
How to confirm mcrypt is insalled ?
This comment has been minimized.
Copy link Quote reply
HenkPoley commented Jul 15, 2020
php -m lists your active modules.
This comment has been minimized.
Copy link Quote reply
konstantinosbotonakis commented Sep 28, 2020 •
For Windows Users
- Check in your PHP Info if your PHP is 32bit (x86) or 64bit (x64)
- Now visit: https://pecl.php.net/package/mcrypt/1.0.3/windows and download the appropriate version for your PHP’s version and the architecture.
- Again in your PHP info page, search for var: extension_dir and open the directory.
- Unzip the file you downloaded from the above url.
- Open your XAMPP’s or MAMP’s php.ini file. In case you don’t know where is it, you can find it from your php info page again:
- Inside the php.ini file, find where the extensions are loaded. It should be lines like: extension=php_curl.dll etc.
- Add a new line: extension=php_mcrypt.dll and save the file changes.
- Now restart XAMPP/MAMPP or apache in general.
You should be able to see something like the following:
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.