Laravel Requires the Mcrypt PHP Extension
- Article
- Comment (8)
Laravel Requires the Mcrypt PHP Extension for 256-bit encryption/decryption. It is a encryption Algorithm,Supports many encryption algorithms. Here is the list of supported encryption’s.
- DES,
- TripleDES,
- Blowfish (default),
- 3-WAY,
- SAFER-SK64,
- SAFER-SK128,
- TWOFISH, TEA,
- RC2 and GOST in CBC,
- OFB,
- CFB and
- ECB cipher modes.
While Installing Laravel on your local machine, you need to enable Mycrypt to perform authentications.
When you get an error ” Laravel requires the Mcrypt PHP extension” while trying to install laravel, your Server doesnot enabled the Mcrypt extension. Dont get stressed. Its yet simple to enable and install on your Apache. There is a lot more to discuss with it. So lets start with OS based steps to install Mcrypt on your machine. Lets begin with Mac.
MAC :
If you are a Mac User, just follow the steps to enable Mcrypt on your XAMPP.
1. Go to Terminal and Enter which php
2. If it says /usr/bin/php, then proceed with next step .
3. Enter the code.
sudo nano ~/.bash_profile //(or sudo vim ~/.bash_profile if you know how to use it)
4. Then paste this export path
PATH="/Applications/XAMPP/xamppfiles/bin:$PATH"
5, And Press Ctrl – O then enter to save, then ctrl – X to exit. that’s it.
Type
cd ~ type . .bash_profile
than restart terminal again and Enter which php
If you did it right, it should be the same as the path in #4.
if the above steps does not helped, than try this one
brew install php55-mcrypt
* If homebrew Installed this one help you to install Mcrypt in it.
2. Windows :
Open your ” php.ini ” file and goto to bottom and find “mcrypt” and check all the settings are same as the following one.
change from ;extension=php_mcrypt.dll
to extension=php_mcrypt.dll .
and if you can find the above code. use the following method and confirm the following code is one and same.
[mcrypt] ; For more information about mcrypt settings see http://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=
If it’s not commented, change based on the above one. This is tested on Xampp. 1.8.2.
3. Linux :
if you are using Ubuntu, try this.
sudo php5enmod mcrypt
It helped me to install mcrypt. If you cant install try the brief one.
The above one doesnot help you, because your PHP doesnot compiled with Mcrypt. So we need to install it now.
sudo apt-get install php5-mcrypt
The above one helps you to install mcrypt. After installing php5-mcrypt you have to make a symlink to ini files in mods-available Here is the one:
sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/mcrypt.ini
enable:
sudo php5enmod mcrypt
now restart your php5-fpm:
sudo service php5-fpm restart .
That’s it. Remember all the steps needs to restart your server to take effect.
Thanks for your help. In my case I skipped the sym linking step and I went straight to enable module. Then I restarted Apache and everything works. I’m using Ubuntu 14.04 with apache-server^ package.
Thank you for this tutorial.
I have a problem. I search my php.in file, and I was unable to find this line “extension=php_mcrypt.dll”
I am using a fresh installation of the latest version of xampp, which comes with PHP 5.5.15.
And when I am trying to create a new laravel project using composer, it starts downloading all the dependencies, and it stops with an error:
Could not open input file: artisan
Script php artisan clear-compiled handling the post-install-cmd event returned with an error
I appreciate your help and thanks in advance.
Yes, you need Mcrypt to run the Laravel. but, if you have problem on compiler install, there is problem persist in compiler. So try alternative method, install using laravel.phar file , which is more easy compare with compiler commands.
Thanks bro. You helped me.
Thanks buddy,This solved my issue,Thanks again
Man! Thank you so much for this article and tutorial. I spent 3 hours last night trying to install larval without success. But following the steps here for mac users really helps. Thanks a lot guys. this was extremely helpful.
Hello. For me, the filepaths were different, as in, the file structure is /etc/php//mods-available/mcrypt.ini, where version can be something like 7.0 or 8.1. Also, the .ini was already present in mods-available
It depends on the PHP version it will be changed, i wrote the article for php 5.6 i guess.