Plesk

How to install the php-mcrypt module on a Plesk server

Question

mcrypt module is missing for PHP in Tools & Settings > PHP Settings > <PHP version>.
How to install the php-mcrypt module on a Plesk server?

Answer

Plesk PHP handlers up to 7.1 version are shipped with the mcrypt module enabled by default.
PHP handlers provided by Plesk can be installed via Plesk Installer and selected at Domains > example.com > PHP settings.

For other PHP handler versions, mcrypt module must be compiled manually:

For Plesk PHP 7.2 and later versions

Note: mcrypt extension was recently updated and now supports PHP 7.2 and newer. Vote for this feature suggestion for mcrypt support out of the box.

Note: the same procedure can be applied for PHP 7.3 and 7.4

  1. Connect to the server via SSH

  2. Install the required dependencies:

    • On RHEL, CentOS and CloudLinux:

      # yum install -y epel-release

      # yum install --enablerepo=epel -y plesk-php72-devel gcc libmcrypt-devel make

    • On Debian and Ubuntu:

      # apt install -y plesk-php72-dev gcc libmcrypt-dev make libc6-dev

  3. Update pecl.php.net protocols:

    # /opt/plesk/php/7.2/bin/pecl channel-update pecl.php.net

  4. Build the mcrypt extension:

    # /opt/plesk/php/7.2/bin/pecl install mcrypt-1.0.1

    Note: for PHP 7.3 use mcrypt-1.0.2, and mcrypt-1.0.4 for PHP 7.4
    for example: /opt/plesk/php/7.4/bin/pecl install mcrypt

  5. Enable the extension in PHP configuration:

    # echo 'extension=mcrypt.so' > /opt/plesk/php/7.2/etc/php.d/mcrypt.ini

  6. Refresh information about installed PHP modules

    # plesk bin php_handler --reread

  7. To apply changes reload web server Apache (or nginx if Apache is not used) and PHP-FPM service:
    On Ubuntu, Debian:

    # service apache2 reload
    # service plesk-php72-fpm reload

    On CentOS:

    # service httpd reload
    # service plesk-php72-fpm reload

  8. (optional) to make mcrypt manageable via Tools & Settings > PHP Settings > PHP 7.2 > Extensions tab, open php.ini tab under the same path and add extension=mcrypt.so under Dynamic Extensions section. Click OK.

For PHP provided by OS vendor

  1. Connect to a Plesk server via SSH

  2. Install the module:

    • On RHEL-based distributions (RHEL, CentOS, CloudLinux):

      # yum install -y epel-release
      # yum install -y php-mcrypt

    • on Debian-based distributions (Debian, Ubuntu):

      # apt-get install php5-mcrypt -y || apt-get install mcrypt php7.0-mcrypt -y || apt-get install php-mcrypt -y

  3. Refresh information about installed PHP modules

    # plesk bin php_handler --reread

  4. Reload PHP-FPM and Apache  (or nginx if Apache is not used) to make the module available for websites:

    # systemctl reload php-fpm php7.0-fpm apache2 httpd

Solution to fix "Autoconf version 2.68 or higher is required"

Note: In case of below the error

error: Autoconf version 2.68 or higher is required
/usr/bin/m4 failed with exit status: 63

first following steps should be applied to replace Autconf version 2.63 with Autoconf version 2.68 provided by Plesk:

# mv /usr/bin/autoconf{,.bkps}
# ln -s /usr/bin/autoconf268 /usr/bin/autoconf
# mv /usr/bin/autom4te{,.bkps}
# ln -s /usr/bin/autom4te268 /usr/bin/autom4te