When you open the phpMyAdmin login page, you might see an error message that says the mcrypt extension is missing.
The error is as shown below:
This error message appears because phpMyAdmin requires the mcrypt extension.
Sometimes, the error also appears when you run Laravel 4 commands from the terminal:
Laravel requires the Mcrypt PHP extension.
To solve this error, you need to enable the mcrypt extension from the php.ini
file.
If you don’t know where the php.ini
file is located, then run the following command from the terminal:
php -i | grep php.ini
Open the php.ini
file using a text editor, then search for the words “extension=php_mcrypt.dll” in the file.
You need to remove the semicolon (;
) placed in front of the line as shown below:
If you can’t find the “extension=php_mcrypt.dll” line in the file, then you can add it above or below the other lines that say extension.
Finally, restart the Apache or Nginx server you use to run PHP. The error message should disappear when you run phpMyAdmin or Laravel.
If your PHP version is higher than 5.2, then the mcrypt extension is connected statically with the PHP binaries.
To enable the extension, you only need to install it and restart the Apache server.
For example, the following command enables mcrypt for PHP 5.6:
sudo apt-get install php5-mcrypt
sudo service apache2 restart
For PHP 7, run the following commands:
sudo apt-get update
sudo apt-get install mcrypt php7.0-mcrypt
sudo apt-get upgrade
sudo service apache2 restart
You should have mcrypt enabled for your PHP installation.
Keep in mind that the mcrypt extension has been deprecated in PHP version 7.1 and removed in PHP version 7.2.
Both phpMyAdmin and Laravel don’t need mcrypt in their latest versions as well, so you might want to upgrade the software you are using instead of enabling mcrypt.
But if you need to maintain legacy code that uses mcrypt, then the above solution should help you.
You may want to refactor your code to use OpenSSL instead of mcrypt for future compatibility and security.
Now you’ve learned how to solve the “mcrypt extension is missing” error message. Good job!