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

  • Did you install PHP from the package manager (apt-get/aptitude), too? The package php5-mcrypt can only configure the extension for php.inis it "knows" about. Secondly, I don't now if apache2ctl reloads the modules. The "normal" way to restart Apache would be something like sudo service apache2 restart. Third, how is PHP connected to your Apache? If you use something like (f)cgi or php-fpm (in contrast to mod-php), you probably will to have restart PHP on its own, additionally to restarting Apache. Commented Sep 30, 2013 at 18:30
  • We installed everything using aptitude. apache2ctl stops and restarts apache. We've restarted the computer several times since these installs. Trust me when I say apache has been "restarted" since we installed php5-mcrypt - as well as PHP. PHP5 works fine as an apache module - it's a website written in PHP - so I assume PHP is installed as an apache module. If I go to /etc/apache2/mods-enabled php5 is in that list. I do not see mcrypt in /etc/php5/mods-available but if I do sudo aptitude search mcrypt I see 3 things installed: libmcypt4, mcrypt and php5-mcrypt - ???? Commented Sep 30, 2013 at 18:41
  • Which php.ini is listed in the output of phpinfo (about 5th to 7th entry)? It should be a file in /etc/php5/. If you search in that file for mcrypt, what does come up? Commented Sep 30, 2013 at 19:00
  • php.ini is in /etc/php5/apache2/php.ini there is an mcrypt section in there with 2 settings - both commented out - mcrypt.algorithms_dir and mcrypt.modes_dir the comments above them say the default is /usr/local/lib/libmcrypt - those directories do not exist. This is what first clued me into the fact that mcrypt may not be installed although aptitude says it is. If I do sudo aptitude info mcrypt is says the package state is installed - version 2.6.8-1.3 - it says Conflicts: mcrypt - so what is it saying? that this package conflicts with itself? Is there a better way to encrypt user info? Commented Sep 30, 2013 at 19:54
  • You don't need to care about the mcrypt package. That's the command line program that uses libmcrypt, as does the PHP extension. So you need to make sure the package libmcrypt4 is installed. Is there a php.ini snippet at /etc/php5/conf.d/mcrypt.ini? That should load the lib. Is that snippet loaded by PHP (see phpinfo)? Again, have you tried to restart Apache with sudo service apache2 restart instead of apache2ctl? Commented Sep 30, 2013 at 22:13

5 Answers 5


Try this

sudo php5enmod mcrypt

sudo service apache2 restart
  • Worked nicely and the symlink (over copying whole thing) is +1 for me. So upvoted! Commented Apr 1, 2014 at 8:25
  • 4
    This worked for me. But I did not need the first command (ln). I had no mcrypt.ini within the /etc/php5/apache/conf.d folder. Running sudo php4enmod mcrypt worked. File there now. Server works!. Thanks a lot.
    – peterept
    Commented Apr 27, 2014 at 1:22
  • 1
    Thanks its working fine. But I want know about the command that you used "sudo php5enmod mcrypt"..What is this ..? Whats the purpose of using this command..?
    – Elavarasan
    Commented Jun 16, 2014 at 11:34
  • 1
    "sudo php5enmod mcrypt" will create a symlink in "/etc/php5/conf.d" directory with a priority number (default 20) so you can uninstall it without modifying ini files with "sudo php5dismod mcrypt"
    – Vizjerai
    Commented Sep 8, 2014 at 15:57

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

  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!

  • Thanks so much for this answer. Totally sorted me out. Although I didn't move /etc/php5/conf.d/mcrypt.ini - I just set my symbolic links to point to that location which also worked and presumably will ensure future updates to mcrypt are automatically loaded? Commented Jun 20, 2014 at 6:56

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

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.


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

sudo php5enmod mcrypt
sudo service apache2 restart

Well, this is it. Looks like sometimes we are in search of the most tangled way to do something as simple as 'enmod' ; ) Like Boinst says: sudo php5enmod mcrypt. Then reload apache.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .