Issue in installing php7.2-mcrypt

157,392

Solution 1

I followed below steps to install mcrypt for PHP7.2 using PECL.

  1. Install PECL

apt-get install php-pecl

  1. Before installing MCRYPT you must install libmcrypt

apt-get install libmcrypt-dev libreadline-dev

  1. Install MCRYPT 1.0.1 using PECL

pecl install mcrypt-1.0.1

  1. After the successful installation

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

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

IMPORTANT !

According to php.net reference many (all) mcrypt functions have been DEPRECATED as of PHP 7.1.0. Relying on this function is highly discouraged.

Solution 2

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

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

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

Solution 3

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

  • Check if you have pear installed (or install):

$ sudo apt-get install php-pear

  • Install, if isn't already installed, php7.2-dev, in order to avoid the error:

sh: phpize: not found

ERROR: `phpize’ failed

$ sudo apt-get install php7.2-dev

  • Install mcrypt using pecl:

$ sudo pecl install mcrypt-1.0.1

  • Add the extention extension=mcrypt.so to your php.ini configuration file; if you don't know where it is, search with:

$ sudo php -i | grep 'Configuration File'

Solution 4

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

x is your php version like 7.2 the 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"

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

Solution 5

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

Install 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 mcrypt by sudo phpenmod mcrypt, it gets available.

Share:
157,392
Nɪsʜᴀɴᴛʜ ॐ
Author by

Nɪsʜᴀɴᴛʜ ॐ

Email: [email protected] I'm neither a Data Scientist nor a Software Developer or a Pragmatic Programmer and Guess What?!... Rubber Ducking the problem & walking through — the path in solving Rubik's Cube puzzle, leading to the stream places of a mysterious journey on the way Thinking aloud by the end of the day, the result will be in the Eureka effect as an upthrust force gained against realizing, the density, W.E.F. the upfront time spent across the quacking duck 웃 In spirit of Knuth, I thrive through the good and optimized code until I no longer see the difference between profession and art. As I'm allergic to spaghetti code, compared with Lasagna & Ravioli code. 🐵 - 🍵 - 🎅 - 🌲 - 🚀 UX (User experience) DX (Developer experience) CX (Contributor experience) AX (Accessibility experience) Live Technical Support (L1) MVA C# Corner CODE Project ASP.NET Forums ASP FORUMS MSDN Forums .NET Developer Community Microsoft's Open Source Code Developers Methodologies Agile Scrum Kanban Pair programming Extreme programming (XP) Formal standard such as ISO 9001 or IEEE 12207 (aka “waterfall” methodologies) Lean Evidence-based software engineering Mob programming PRINCE2 CMM/CMMI Level 5 ISO 8000/9000/9001/14001/18001/45001/20000/22000/27001/ Viewing Query 🕉 卐 ☮ ☸ ✡ ☦ ☯ ⚛ ✡ ❖ © ® ▲ ◄ ► ▼ • ☆ ★ ♀ ¾ ½ ¼ ² ³ ¹ ± α β ♦ → ♫ ♪ ツ † Moves = 2^(n) − 1

Updated on June 22, 2021

Comments

  • Nɪsʜᴀɴᴛʜ ॐ
    Nɪsʜᴀɴᴛʜ ॐ almost 3 years

    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.2 during installation!

    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

    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.

    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.

    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 found from 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.

    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

  • Vincent Decaux
    Vincent Decaux about 6 years
    On debian, for step 1, use apt-get install php-pear to use PECL command.
  • Simon Hayter
    Simon Hayter about 6 years
    php-pear is also used for Ubuntu
  • The One
    The One about 6 years
    How to make this work on amazon linux 1 with php7.2 installed from source?
  • Praneeth Nidarshan
    Praneeth Nidarshan about 6 years
    @TheOne try this command to install pear --> yum install php-pear then you follow from step 3
  • The One
    The One about 6 years
    @PraneethNidarshan it didn't work. Because as i installed using the above command line, it went with php5.3 packages and i finally ended up overwrite my php7.2 with php 5.3
  • Pragnesh Karia
    Pragnesh Karia about 6 years
    what about WAMP in windows ? PHP > 7.0
  • Alberto
    Alberto almost 6 years
    @pragnesh-karia although it is possible to install that library on Windows, it will save you A LOT of trouble if you use a linux Vagrant machine
  • Tuxman
    Tuxman over 5 years
    This answer it's ok, but I have to install the php-dev package also.
  • Kapur
    Kapur about 5 years
    @Praneeth Nidarshan, how to install Mcrypt extension in local XAMPP for Windows 7.3.2?
  • Arda
    Arda almost 5 years
    @PrafullaKumarSahu You need php-pear, php-dev, and libmcrypt-dev packages installed to run these commands.
  • Gem
    Gem over 4 years
    @PraneethNidarshan How to do in windows os?
  • Gem
    Gem over 4 years
    @PragneshKaria did you find any solutions?
  • Praneeth Nidarshan
    Praneeth Nidarshan over 4 years
    @Gem, MCrypt methods have been DEPRECATED as of PHP 7.1.0. Relying on this function is highly discouraged.
  • Ejaz
    Ejaz over 4 years
    Installing '/usr/lib/php/20170718/mcrypt.so' I have multiple PHP versions on my machine. My current PHP CLI version is 7.2 but when I install mcrypt, it is installed for PHP 5.6. How do I install it for 7.2?
  • cdsaenz
    cdsaenz over 3 years
    After hours of research the bit I needed was the last paragraph! in my case it was: sudo phpenmod -v 7.3 mcrypt
  • Čamo
    Čamo over 3 years
    what about php7.4 Can I forget this package as it is deprecated?