How to encable mCrypt in php7.3?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hey @danielzhang,
The
mcrypt
library was deprecated in PHP 7.1, and it was removed entirely in PHP 7.2. If you’re using PHP 7.3 or a later version, you can’t enable mcrypt in the same way as before. Instead, you’ll need to use a different method.However, if you still need to use mcrypt due to some legacy code that you can’t update to use a more modern encryption method, there’s a PECL extension available that brings back mcrypt to PHP 7.3.
Install prerequisites
Before you install the mcrypt extension, you’ll need to make sure that you have some necessary packages installed on your system.
On Ubuntu:
On CentOS:
Install mcrypt extension
After you’ve installed these packages, you can install the mcrypt extension itself:
During the installation, you may be asked for the libmcrypt prefix. If you are, press enter to skip.
Configure PHP to use the mcrypt extension
After the installation is complete, you’ll need to tell PHP to use the mcrypt extension. To do this, you’ll need to modify your php.ini file.
First, you’ll need to find it. You can do this by using the following command:
Look for the line that says “Loaded Configuration File”. This will tell you where your php.ini file is located.
Open this file with your favorite text editor (like nano or vim). For example:
Add the following line to the file:
Restart your web server
Finally, you’ll need to restart your web server for the changes to take effect.