can't find mcrypt => Call to undefined function Laravel\mcrypt_create_iv()
Solution 1
You need to enable it in your php.ini
file as well and probably restart Apache.
In php.ini
you will find ;mcrypt.so
and remove the ;
from it.
Or, if it's not in there, just add mcrypt.so
somewhere.
Also the salt option has been deprecated as of PHP 7.0.0. It is now preferred to simply use the salt that is generated by default.
Solution 2
Ubuntu or any Debian based Linux users can install the required package with apt-get
:
sudo apt-get install php5-mcrypt
Remember to restart the web server afterwards:
sudo service apache2 restart
If it still doesn't work, try to link the configuration file to the appropriate configuration folder for the web server. Thanks to dave1010 for this hint in the comments.
sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/apache2/conf.d/ # for Apache
sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/cli/conf.d/ # for CLI
And again, restart the web server:
sudo service apache2 restart
Perhaps, if not working yet, you need also the line showed by @RahulPrasad, with php5enmod mcrypt
.
Solution 3
Try sudo php5enmod mcrypt && sudo service apache2 restart
Solution 4
You've installed mcrypt
when you actually wanted the php56-mcrypt
php module.
You stated in your question that you can see mcrypt
installed in /usr/local/Cellar
and that you're using OSX
. So, the easiest way to install the mcrypt PHP module on OSX using Homebrew is:
// assuming you have php56
brew install php56-mcrypt
If homebrew can't find the correct package you may need to tap the PHP repositories found on GitHub:
brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
Now when you issue the command brew search mcrypt
, you should see something like:
libtomcrypt mcrypt php53-mcrypt php54-mcrypt php55-mcrypt php56-mcrypt
Several other posters have mentioned the need to edit your php.ini
file. This will be unnecessary as homebrew will take care of activating the module for you. It places the configuration file at /usr/local/etc/php/5.6/conf.d/ext-mcrypt.ini
Solution 5
You don't have the mcrypt PHP extension installed.
For a Mac, I followed these instructions: mcrypt on Mac 10.7 or 10.8.
They look like a lot, but it's not, it's very easy to follow in it works!
Related videos on Youtube
Comments
-
coryj over 4 years
Trying to set up Laravel and keep getting hit with this error. I installed mcrypt through brew and it is located in /usr/local/Cellar. Any thoughts? .. It's not showing up in terminal command php -m either, if that matters. I'm running Mountaion Lion with macs native web server.
-
Amit Erandole over 11 yearsYou need to recompile php again
-
-
coryj over 11 yearsDidn't seem to work.. Found this line of code
code
[mcrypt] ; For more information about mcrypt settings see php.net/mcrypt-module-open ; Directory where to load mcrypt algorithms ; Default: Compiled in into libmcrypt (usually /usr/local/lib/libmcrypt) ;mcrypt.algorithms_dir= ; Directory where to load mcrypt modes ; Default: Compiled in into libmcrypt (usually /usr/local/lib/libmcrypt) ;mcrypt.modes_dir=code
-
coryj over 11 yearsThis is what finally helped me if anyone else browsing has this same issue. Thank you guys for your quick responses! => coolestguyplanettech.com/…
-
Deinumite over 11 years@coryjacik It depends on how you've compiled mcrypt, I should have specified that probably.
-
dualed over 11 years@coryjacik Thanks for the link, I followed that guide too. But even though on my system, autoconf was already installed, I had to
sudo ln -s /Developer/usr/share/autoconf /usr/share/
to get/usr/share/phpize
working. -
Carlton almost 11 yearsDid the apt-get part and that my web server config was reloaded but needed a restart like Sophy mentions
-
aymericbeaumet over 10 yearsThe PO should definitely use these solution to solve his problem...
brew
is the way to install packages on Mac OS X. -
dave1010 over 10 yearsFor some reason on Ubuntu, PHP wasn't picking up the mcrypt.ini. This fixed it:
sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/apache2/conf.d/ ; sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/apache2/conf.d/
-
theycallmemorty about 10 yearsThis doesnt work for me...
Error: No available formula for php55
-
leemes about 10 years@dave1010 Yeah that did it, thank you very much!! But why the same command twice?
-
dave1010 about 10 years@leemes good spot. It should have been going into the
apache2
andcli
directories (or whatever SAPIs you use):sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/apache2/conf.d/ ; sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/cli/conf.d/
-
leemes about 10 years@dave1010 Ah okay. I guess almost nobody noticed that mistake because most people use Apache :)
-
leemes about 10 years@dave1010 I hope it's okay that I copied this information into the answer so that future readers can spot it quickly.
-
frederickf over 9 yearsFor me the mcrypt.ini what at
/etc/php5/mods-available/mcrypt.ini
. I'm using Ubuntu 14.04 LTS and PHP 5.5.9-1ubuntu4.3. -
Peter Krauss over 9 years
mcrypt.so
?? phpinfo() say that my php.ini is ` /etc/php5/apache2/php.ini`, and there are NO string "mcrypt.so"! -
Peter Krauss over 9 yearsGood, now it is working (and after @Sophy procedures)!
-
Jimmy Knoot about 9 yearsIt actually does make sense, the PHP you use at the command line (cli) can use a different php.ini than the PHP your webserver uses, you should make a phpinfo file and check what the webserver is using.
-
ppostma1 almost 9 yearsnew versions of debian/ubuntu are easier (and require)
apt-get install php5-mcyrpt
;,php5enmod mcrypt
;,service php5-fpm restart
-
hash almost 9 yearsThis is the correct way to install
mcrypt
and also remember after run this commandbrew search mcrypt
you want to install mcrypt usingbrew install php56-mcrypt
-
user110857 over 8 years@JimmyKnoot Thanks, I wasn't aware.
-
slevin over 6 yearsBy the way ,
mcrypt_create_iv
is DEPRECATED in PHP 7.1.0. Seehttp://php.net/manual/en/function.mcrypt-create-iv.php
-
arthropod over 5 yearsFor Debian 9 and PHP 7 the needed package is
php7.0-mcrypt
.