Ubuntu and PHP 5 “mcrypt extension is missing” error


After installing lamp-server or the individual php5-mcrypt package, you may come across the following error (e.g. in phpMyAdmin):

The mcrypt extension is missing. Please check your PHP configuration.

The problem is simply because the module is not enabled by default after installation. To enable, execute:

sudo php5enmod mcrypt

and then restart the Apache server using:

sudo /etc/init.d/apache2 restart
sudo service apache2 restart