Install mcrypt for PHP 7.2 / 7.3 on DirectAdmin server

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.

How to install mcrypt extension for PHP 7.2

To be short here you can find a list of commands to run as root in a bash console:

cd /usr/local/src
rm -rf mcrypt-*
/usr/local/php72/bin/pecl channel-update pecl.php.net
/usr/local/php72/bin/pecl download mcrypt || /usr/local/php72/bin/pecl download channel://pecl.php.net/mcrypt-1.0.2
tar -zxvf mcrypt-*.tgz && cd mcrypt-*/
/usr/local/php72/bin/phpize
./configure --with-php-config=/usr/local/php72/bin/php-config
make && make install
echo "extension=mcrypt.so" >> /usr/local/php72/lib/php.conf.d/90-custom.ini

Restart PHP-FPM, Apache for changes to take effect.

Now test it:

/usr/local/php72/bin/php -i | grep ^mcrypt

You should see similar output:

mcrypt
mcrypt support => enabled
mcrypt_filter support => enabled
mcrypt.algorithms_dir => no value => no value
mcrypt.modes_dir => no value => no value

How to install mcrypt extension for PHP 7.3

To be short here you can find a list of commands to run as root in a bash console:

cd /usr/local/src
rm -rf mcrypt-*
/usr/local/php73/bin/pecl channel-update pecl.php.net
/usr/local/php73/bin/pecl download mcrypt || /usr/local/php73/bin/pecl download channel://pecl.php.net/mcrypt-1.0.2
tar -zxvf mcrypt-*.tgz && cd mcrypt-*/
/usr/local/php73/bin/phpize
./configure --with-php-config=/usr/local/php73/bin/php-config
make && make install
echo "extension=mcrypt.so" >> /usr/local/php73/lib/php.conf.d/90-custom.ini

Restart PHP-FPM, Apache for changes to take effect.

Now test it:

/usr/local/php73/bin/php -i | grep ^mcrypt

You should see similar output:

mcrypt
mcrypt support => enabled
mcrypt_filter support => enabled
mcrypt.algorithms_dir => no value => no value
mcrypt.modes_dir => no value => no value

That’s it.

3 Replies to “Install mcrypt for PHP 7.2 / 7.3 on DirectAdmin server”

  1. Hi, I do believe this is an excellent blog. I stumbledupon it 😉 I will return once again since I
    saved as a favorite it. Money and freedom is the greatest way
    to change, may you be rich and continue to help others.

Leave a Reply

Your email address will not be published. Required fields are marked *