Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install PHP 7.2 / PHP 7.3 MCrypt extension (see https://lukasmestan.com/install-mcrypt-extension-in-php7-2/ )
##
## 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
@vermaysha

This comment has been minimized.

Copy link

@vermaysha vermaysha commented Apr 15, 2018

Thanks, it is work

@khoi-thinh

This comment has been minimized.

Copy link

@khoi-thinh khoi-thinh commented Apr 18, 2018

How to do this with Amazon Linux 1?

@didinkaj

This comment has been minimized.

Copy link

@didinkaj didinkaj commented Apr 23, 2018

how about windows version

@footniko

This comment has been minimized.

Copy link

@footniko 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.

@9073241516

This comment has been minimized.

Copy link

@9073241516 9073241516 commented Apr 28, 2018

Hi,

is there a 'mcrypt' for PHP 7.2 on Windows?

@9073241516

This comment has been minimized.

Copy link

@9073241516 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

@9073241516

This comment has been minimized.

Copy link

@9073241516 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...

@9073241516

This comment has been minimized.

Copy link

@9073241516 9073241516 commented Apr 28, 2018

I found some 'tricks' to put that module work on Linux PHP v7.2:

https://stackoverflow.com/questions/48275494/issue-in-installing-php7-2-mcrypt/50079503#50079503

@9073241516

This comment has been minimized.

Copy link

@9073241516 9073241516 commented Apr 28, 2018

@yatskanich

This comment has been minimized.

Copy link

@yatskanich yatskanich commented Apr 29, 2018

Thanks! It works!

@juanesrios

This comment has been minimized.

Copy link

@juanesrios juanesrios commented May 1, 2018

add:
sudo apt-get install php7.2-dev

@luis02lopez

This comment has been minimized.

Copy link

@luis02lopez 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"

@rahmanfrictionless

This comment has been minimized.

Copy link

@rahmanfrictionless rahmanfrictionless commented Jun 4, 2018

Thanks!

@computerfever

This comment has been minimized.

Copy link

@computerfever computerfever commented Jun 8, 2018

how to install Php mcrypt extension in php 7.2.4 on windows xamp

@codecreate-dev

This comment has been minimized.

Copy link

@codecreate-dev codecreate-dev commented Jun 17, 2018

Thanks. worked perfectly Ubuntu 18.04.

@Vannoch91

This comment has been minimized.

Copy link

@Vannoch91 Vannoch91 commented Jun 20, 2018

Dear all, anyone can show me How to fix on Mcrypt php extension required on PHP 7.2?

@1988gadocansey

This comment has been minimized.

Copy link

@1988gadocansey 1988gadocansey commented Jun 25, 2018

Excellent

@yogirzlsinatrya

This comment has been minimized.

Copy link

@yogirzlsinatrya yogirzlsinatrya commented Jul 12, 2018

there is no solution for PHP 7.2 in XAMPP windows ?

@nagarajsajjan

This comment has been minimized.

Copy link

@nagarajsajjan nagarajsajjan commented Jul 12, 2018

It Worked for me, Thank you
Final step - sudo service apache2 restart

@fipso

This comment has been minimized.

Copy link

@fipso fipso commented Jul 25, 2018

Thanks a lot

@battoni

This comment has been minimized.

Copy link

@battoni battoni commented Aug 8, 2018

Worked like a charm!
Thanks man!

@sirdavincci

This comment has been minimized.

Copy link

@sirdavincci sirdavincci commented Aug 21, 2018

Thanks bro!. Worked awesome.

@ThakurPradeep

This comment has been minimized.

Copy link

@ThakurPradeep ThakurPradeep commented Aug 28, 2018

Thanks, It's working fine.

@Dhayllin

This comment has been minimized.

Copy link

@Dhayllin Dhayllin commented Aug 30, 2018

Muito bom !

@XIAOXIAOSIYU

This comment has been minimized.

Copy link

@XIAOXIAOSIYU XIAOXIAOSIYU commented Sep 18, 2018

Still wondering if there is a successful version for PHP7.2 on WINDOWS, thanks!
capture

@nimaamiri92

This comment has been minimized.

Copy link

@nimaamiri92 nimaamiri92 commented Oct 1, 2018

Any solution windows servers?

@suebphatt

This comment has been minimized.

Copy link

@suebphatt suebphatt commented Oct 17, 2018

Saved my day!

@reganto

This comment has been minimized.

Copy link

@reganto reganto commented Oct 21, 2018

Thank you .
Its works :)

@Chibuikekenneth

This comment has been minimized.

Copy link

@Chibuikekenneth Chibuikekenneth commented Nov 30, 2018

thanks, it works

@4nd12i

This comment has been minimized.

Copy link

@4nd12i 4nd12i commented Jan 28, 2019

Thank's it solved my problem...

@akamomer

This comment has been minimized.

Copy link

@akamomer akamomer commented Feb 3, 2019

Worked for me also many thanks 👍

@ShahzadAhmed

This comment has been minimized.

Copy link

@ShahzadAhmed 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.

@manojkumar-iksula

This comment has been minimized.

Copy link

@manojkumar-iksula manojkumar-iksula commented Mar 28, 2019

yup its work....!!!

@MrPetovan

This comment has been minimized.

Copy link

@MrPetovan MrPetovan commented Apr 18, 2019

Thanks! On my Devuan (Debian minus systemd) server, the only change I made was instead of

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"

I did

sudo bash -c "echo extension=/usr/lib/php/20170718/mcrypt.so > /etc/php/7.3/mods-available/mcrypt.ini"
sudo phpenmod mcrypt # (add symlinks in /etc/php/7.3/cli/conf.d/ and /etc/php/7.3/apache2/conf.d/)
@elfeffe

This comment has been minimized.

Copy link

@elfeffe elfeffe commented Jun 18, 2019

For PHP 7.3 this is
sudo pecl install mcrypt-1.0.2

@partuner

This comment has been minimized.

Copy link

@partuner partuner commented Jul 25, 2019

thank you very much , working perfect on ubuntu 18.04.2

@jalmoreno

This comment has been minimized.

Copy link

@jalmoreno jalmoreno commented Aug 1, 2019

Good one!

@yudanilam

This comment has been minimized.

Copy link

@yudanilam yudanilam commented Aug 8, 2019

Thanks...its works...!!!

@kevinski303

This comment has been minimized.

Copy link

@kevinski303 kevinski303 commented Aug 14, 2019

pecl install mcrypt-1.0.2

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

@Resmedia

This comment has been minimized.

Copy link

@Resmedia Resmedia commented Aug 18, 2019

For PHP 7.3 this is
sudo pecl install mcrypt-1.0.2

Thank's it works!

@dave-lw

This comment has been minimized.

Copy link

@dave-lw dave-lw commented Aug 29, 2019

thanks, worked on my windows linux subsystem,
php 7.2 i believe on ubuntu.

@fedorovvldmr

This comment has been minimized.

Copy link

@fedorovvldmr 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

@dave-lw

This comment has been minimized.

Copy link

@dave-lw dave-lw commented Dec 21, 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

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

@dave-lw

This comment has been minimized.

Copy link

@dave-lw dave-lw commented Dec 21, 2019

i'd remove everything then do the following:
https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-ubuntu-18-04
and then
https://lukasmestan.com/install-mcrypt-extension-in-php7-2/

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

@fedorovvldmr

This comment has been minimized.

Copy link

@fedorovvldmr fedorovvldmr commented Dec 21, 2019

@dave-lw, i installed it form source code (gist)

@dave-lw

This comment has been minimized.

Copy link

@dave-lw 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.

@HenkPoley

This comment has been minimized.

Copy link

@HenkPoley HenkPoley commented Jan 22, 2020

For Xampp you can look for the DLL links here: https://pecl.php.net/package/mcrypt

E.g. for my Xampp with PHP 7.3.12, I downloaded 7.3 Thread Safe (TS) x64 from here: https://pecl.php.net/package/mcrypt/1.0.3/windows

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.

@abenitesvil

This comment has been minimized.

Copy link

@abenitesvil abenitesvil commented Apr 21, 2020

You saved my day

@afoysal

This comment has been minimized.

Copy link

@afoysal afoysal commented Jul 15, 2020

For PHP 7.3 this is
sudo pecl install mcrypt-1.0.2

How to confirm mcrypt is insalled ?

@HenkPoley

This comment has been minimized.

Copy link

@HenkPoley HenkPoley commented Jul 15, 2020

php -m lists your active modules.

@konstantinosbotonakis

This comment has been minimized.

Copy link

@konstantinosbotonakis konstantinosbotonakis commented Sep 28, 2020

For Windows Users

  • Check in your PHP Info if your PHP is 32bit (x86) or 64bit (x64)
    image
  • 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.
    image
  • 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:
    image
  • 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.

It's ready!

You should be able to see something like the following:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.