How can I install mcrypt under PHP7? Laravel needs it

59,319

Solution 1

Had the same issue - PHP7 missing mcrypt.

This worked for me. When asked, keep local PHP configuration files.

sudo apt-get update
sudo apt-get install mcrypt php7.0-mcrypt
sudo apt-get upgrade

Restart FPM (or Apache or NGINX etc.) after installation.

Solution 2

I'm on Mac and with laravel valet I've solved with this:

brew install php70-mcrypt

Solution 3

Even if you enable mcrypt in php.ini, this issue may occur. Try the following steps.

sudo apt-get update
sudo apt-get install mcrypt php7.0-mcrypt

I am working in ubuntu 16.04 and the following commands also helped me.

whereis php  -shows the files with this name
php -v   -shows the php version
which php -shows current php version that is running on the server

Solution 4

On ubuntu: According to launchpad.net the package for mcrypt is called php7.0-mcrypt.

sudo apt-get install php7.0-mcrypt to install

Solution 5

Open terminal with Ctrl + Alt + T and run following commands for PHP7.0 on Ubuntu 16.4

sudo apt-get install mcrypt php7.0-mcrypt
sudo service apache2 restart
Share:
59,319
Bishal Paudel
Author by

Bishal Paudel

Entrepreneurial developer with 5 years of experience producing e-commerce web applications and firmware. Proven ability to manage complete software development lifecycle (SDLC) as both contributor and team leader. Demonstrated talent for improving productivity and efficiency. Passionate about engineering high-tech solutions for real-world problems. Established capacity for working with very large data sets. Track record of meeting tight deadlines and commercial quality requirements.

Updated on July 09, 2022

Comments

  • Bishal Paudel
    Bishal Paudel almost 2 years

    Since Laravel4 requires mcrypt extension, and PHP7 doesn't seem to have mcrypt extension, is there any workaround for this to work?

  • Bishal Paudel
    Bishal Paudel over 8 years
    Can you please elaborate how I install PHP7 Mcrypt? I tried to find if PHP7 has any Mcrypt extension, but to no avail. PHP5 had Mcrypt as php5-mcrypt which can be enabled and disabled easily with php5enmod and php5dismod respectively.
  • Tom Davies
    Tom Davies about 8 years
    This worked for me when the ppa for installation via apt-get was failing, so thanks! Would be great if you could fix the formatting in your answer though as it's a little hard to follow.
  • user985366
    user985366 almost 8 years
    I had to do this first sudo add-apt-repository ppa:ondrej/php
  • Osama Al-Banna
    Osama Al-Banna over 7 years
    @user985366 thanks ...yes we have to do this sudo add-apt-repository ppa:ondrej/php and then sudo apt-get update sudo apt-get install mcrypt php7.0-mcrypt sudo apt-get upgrade and then it worked for me
  • user3707264
    user3707264 over 7 years
    In /etc/php/7.0/cli/conf.d/20-mcrypt.ini you have to check that the extension is enabled: extension=mcrypt.so and not ;extension=mcrypt.so
  • enchance
    enchance over 7 years
    @Ryderpro Do we need to install mcrypt when we're already getting php7.0-mcrypt? Or are they 2 diff things entirely?