phpMyAdmin: Missing Mcrypt Extension

If you’ve set up a web server recently that included PHP, you likely installed PHP’s Mcrypt extension. However, a lot of explanations on setting up a LAMP web server mention installing the extension, but not enabling it. If you’ve installed phpMyAdmin, you have likely seen the The mcrypt extension is missing. Please check your PHP configuration. error message at the bottom of the initial page after logging in.

Fixing this issue is as simple as two commands, at least in Ubuntu/Debian.

sudo php5enmod mcrypt
sudo service apache2 reload

You’ll have to log back into phpMyAdmin once you’ve reloaded Apache’s configuration, but you’ll see the error message is now gone.

If you didn’t actually install the Mcrypt extension when you installed PHP, you can do that before entering the above commands by first entering:

sudo apt-get install php5-mcrypt

If you’re unsure if Mcrypt has been installed, you can check for it by entering:

apt-cache policy php5-mcrypt

The output of the apt-cache policy php5-mcrypt command on a system where the package is not installed will look something like:

php5-mcrypt:
  Installed: (none)
  Candidate: 5.4.6-0ubuntu5
  Version table:
     5.4.6-0ubuntu5 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty/universe amd64 Packages

If it is installed, it would look something like:

php5-mcrypt:
  Installed: 5.4.6-0ubuntu5
  Candidate: 5.4.6-0ubuntu5
  Version table:
 *** 5.4.6-0ubuntu5 0
        500 http://archive.ubuntu.com/ubuntu/ trusty/universe amd64 Packages
        100 /var/lib/dpkg/status

Some information would vary, depending on the OS and the repositories your server uses, but the output of the command would be roughly the same (on Debian/Ubuntu), and will tell you if the package is installed and what version. You can also use this command to see what version any particular package is on the repositories your Ubuntu/Debian installation pulls from.