In the examples shown, replace “X.Y” with your app’s PHP version (for example, “7.2”).
The mcrypt extension is an interface to the mcrypt cryptography library. This extension is useful for allowing PHP code using mcrypt to run on PHP 7.2+.
The mcrypt extension is included in PHP 5.4 through PHP 7.1. It was removed from PHP 7.2 and moved to an unofficial PECL extension because the mcrypt library is no longer maintained.
For PHP 7.2+, PHP instead uses libsodium as a cryptography library. ServerPilot builds PHP 7.2+ with the official libsodium extension. New PHP code should be written to use libsodium rather than mcrypt.
Installing mcrypt on PHP 5, PHP 7.0, and PHP 7.1
You do not need to install the mcrypt extension on PHP 5, 7.0, or 7.1. ServerPilot builds these PHP versions with the mcrypt extension so it is always available.
Installing mcrypt on PHP 7.2, 7.3, or 7.4
To install this extension on PHP 7.2 through 7.4, run the following commands as your server’s root user:
sudo apt-get -y install libmcrypt-dev
sudo pecl7.2-sp install --nodeps mcrypt-snapshot
When you are shown the prompt
Press Enter to autodetect.
Once installed, create a configuration file for the extension and restart PHP by running the following commands as root:
sudo service php7.2-fpm-sp restart
Verifying mcrypt Is Installed
You can check that the extension was installed with this command:
The output will look like this:
Registered Stream Filters => zlib.*, convert.iconv.*, bzip2.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, mcrypt.*, mdecrypt.*
mcrypt support => enabled
mcrypt_filter support => enabled
mcrypt.algorithms_dir => no value => no value
mcrypt.modes_dir => no value => no value
Uninstalling the Mcrypt Extension
To uninstall this extension, as root run the commands:
sudo peclX.Y-sp uninstall mcrypt
Next, restart PHP-FPM with the command: