Cannot get mcrypt for PHP5

I've done this many times:

sudo aptitude install php5-mcrypt

sudo apache2ctl restart

aptitude says mcrypt is installed. I've reinstalled it 3 times already. I've restarted apache about 20 times since I installed it. When I look at phpInfo, I do not see mcrypt listed. When I try to execute my code it says the mcrypt function (pick one - any one) does not exist. mcrypt is clearly not enabled.

Does anyone have any idea what could be wrong? I do not know which pieces should be where and how all this is supposed to fit together.

I installed PHP 5.5.3


Solution 1:

Try this

sudo php5enmod mcrypt

sudo service apache2 restart

Solution 2:

I had a similar problem on Ubuntu 13.10. Upon running composer install it produced the same error, ending in.

****Mcrypt PHP extension required.
Script php artisan clear-compiled handling the post-update-cmd event returned with an error

  [RuntimeException]  
  Error Output:****   

I installed mcrypt and php5-mcrypt with aptitude, and still php -m did not show mcrypt as a loaded extension:

aptitude install mcrypt
aptitude install php5-mcrypt

I ran an updatedb, and then locate mcrypt. I found my mcrypt.ini in /etc/php5/conf.d. Yet all the other extensions (like json) had their .ini files in /etc/php5/apache2/conf.d and /etc/php5/cli/conf.d. These both were links to ../../mods.available.

So, I then moved mcrypt.ini to /etc/php5/available-modules, and set the links:

cd /etc/php5/cli/conf.d
ln -s ../../mods-available/mcrypt.ini 20-mcrypt.ini

And similarly for /etc/php5/apache2/conf.d.

And voila, it showed up in php -m!

Solution 3:

Looks like the ini snippet that load libmcrypt when PHP is called by Apache is missing. There should be a file called /etc/php5/apache2/conf.d/mcrypt.ini with the following content

; configuration for php MCrypt module
extension=mcrypt.so

You should be able to copy it from the other PHP integration's vonfigurations like /etc/php5/cli/conf.d/mcrypt.ini or /etc/php5/conf.d/mcrypt.ini, depending on what's installed on your system.

Solution 4:

The mcrypt module is not enabled by default. Enable the mcrypt module and then restart apache (credit)

sudo php5enmod mcrypt
sudo service apache2 restart