92
votes

After I have upgraded my system from Ubuntu 13.04 to 13.10 several problems have occurred with apache, mysql and php configurations.

I solved most of them but I can't seem to get mCrypt library working. Package is installed so i don't need to apt-get it. Server works and everything seems fine, but when I try to run php artisan serve with Laravel 4, I get a message that mCrypt is required.

I did php --ri mcrypt and the output was Extension 'mcrypt' not present. I have tried putting extension=mcrypt.so to /etc/php5/apache2/php.ini but it didn't work.

Any ideas?

Output of dpkg --get-selections | grep php5

libapache2-mod-php5         install
php5                        install
php5-cli                    install
php5-common                 install
php5-gd                     install
php5-json                   install
php5-mcrypt                 install
php5-mysql                  install
php5-readline               install
10
Are you sure it's installed dpkg --get-selections | grep php5tlenss
apt-get install php5-mcrypt ?Lajos Veres
I have updated question with output of @tlenss command. sudo apt-get install php5-mcrypt outputs that it is installed and newest versionVuk Stanković
Maybe the answer here will help you askubuntu.com/questions/360646/…tlenss
Found launchpad bug on that page that gave me solution. ThanksVuk Stanković

10 Answers

273
votes

I think I found the solution at launchpad.net.

sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available
sudo php5enmod mcrypt
sudo service apache2 restart

This worked for me.

27
votes

I had this problem with Ubuntu 14.04 and I did the following to resolve it:

sudo apt-get install php5-mcrypt
sudo php5enmod mcrypt

sudo service apache2 restart
14
votes

I also have this problem with Ubuntu 14.04 after install.

First enable the mcrypt

sudo gedit /etc/php5/apache2/php.ini

Add this command in any line

extension=mcrypt.so

Create conf.d folder in /etc/php5

sudo mkdir conf.d

And inside that folder create mcrypt.ini file

sudo gedit mcrypt.ini 

Then add this command to that file

extension=mcrypt.so

Then create a link to file

sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available

Enable mcrypt module

sudo php5enmod mcrypt

Restart apache

sudo service apache2 restart
11
votes

From Ubuntu 13.10 to 14.04:

sudo php5enmod mcrypt
sudo service apache2 restart

Works for me.

3
votes

I also had this problem with Ubuntu 14.04 and Nginx,but the tip for me was restart the FPM service, so I did:

Install the library

apt-get install php5-mcrypt

Find the path

updatedb && locate mcrypt.so

Set the path of mcrypt.so inside the mcrypt.ini file located in /etc/php5/mods-available/mcrypt.ini

extension=/usr/lib/php5/20121212/mcrypt.so

And then restart the FPM service

service php5-fpm restart

0
votes

Another solution if the package is already installed:

sudo aptitude reinstall php5-mycript

This worked for me after doing upgrade

0
votes

Try this code:

ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/apache2/conf.d/20-mcrypt.ini
service apache2 restart
0
votes

I had the same problem with PHP 5.5.14 running on Mac OS X Yosemite. I was trying to install Laravel 5.0. And when I tried to create a new project I got an error like below (even when I tried to start the laravel server with php artisan serve

Alejandros-MacBook-Pro:Documents Lexynux$ laravel new blog
Crafting application...
PHP Notice:  Use of undefined constant MCRYPT_RIJNDAEL_128 - assumed 'MCRYPT_RIJNDAEL_128' in /Library/WebServer/Documents/blog/config/app.php on line 83
PHP Notice:  Use of undefined constant MCRYPT_RIJNDAEL_128 - assumed 'MCRYPT_RIJNDAEL_128' in /Library/WebServer/Documents/blog/config/app.php on line 83
Generating optimized class loader
Compiling common classes
Compiling views
PHP Notice:  Use of undefined constant MCRYPT_RIJNDAEL_128 - assumed 'MCRYPT_RIJNDAEL_128' in /Library/WebServer/Documents/blog/config/app.php on line 83
Application key [CCOPocoMjnJTx4AFXk64wqyTKyo3BlHq] set successfully.
Application ready! Build something amazing.
Alejandros-MacBook-Pro:Documents Lexynux$ 

So I just added the line below at the end of my php.ini file with the nano editor:

extension=mcrypt.so
sudo nano /etc/php.ini

Finally just restart the Terminal and restart the laravel app server with

php artisan serve

And it works fine!

0
votes

just found on php.net

Note, for Ubuntu, simply installing php5-mcrypt did not get mcrypt to work. You need to execute the following commands as root to enable it:

apt-get install php5-mcrypt
mv -i /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/
php5enmod mcrypt
service apache2 restart

http://php.net/manual/en/mcrypt.installation.php#114609

0
votes

Sometimes, this "problem" occurs because you entered an artisan command on your local machine instead of on your virtual machine. If you are using Homestead, mcrypt is already installed. Consider it a reminder to homestead ssh