Applicable to:
- Plesk for Linux
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:
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
-
Connect to the server via SSH
-
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
-
- Update pecl.php.net protocols:
# /opt/plesk/php/7.2/bin/pecl channel-update pecl.php.net
-
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
-
Enable the extension in PHP configuration:
# echo 'extension=mcrypt.so' > /opt/plesk/php/7.2/etc/php.d/mcrypt.ini
-
Refresh information about installed PHP modules
# plesk bin php_handler --reread
-
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 reloadOn CentOS:
# service httpd reload
# service plesk-php72-fpm reload - (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.
-
Connect to a Plesk server via SSH
-
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
-
-
Refresh information about installed PHP modules
# plesk bin php_handler --reread
-
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
Note: In case of below the error
CONFIG_TEXT: 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
Comments
16 comments
Mcrypt updated to 1.0.2 which is fully compatible with 7.2 and 7.3. Please update
Hello @Jacob,
Thank you, I've created a corresponding feature suggestion: https://plesk.uservoice.com/forums/184549-feature-suggestions/suggestions/38282788-add-mcrypt-module-to-plesk-php-7-2-and-newer?
Feel free to vote for and comment it.
It seems like https://github.com/phpseclib/mcrypt_compat might be the ideal option when mcrypt isn't available.
Hello @eurogood,
Thank you for your input.
Indeed mcrypt_compat can be used, however, please note that it was not tested with Plesk yet and mcrypt_compat can be installed on your own risk only.
Hi,
This article it's incomplete. In order to build the library, C++ compiler is needed. If you don't have it, builder will fail. Btw, today the stable working version is 1.0.3.
Adapted from Stackoverflow thread:
Install dependencies and mcrypt library with pecl
When you are shown the prompt
Press [Enter] to autodetect.
After success installing mcrypt trought pecl, you should add mcrypt.so extension to php.ini.
The output will look like this:
Enable the extension in PHP configuration:
Refresh and Reload
Check that everything is working
Cheers
Hello,
Thank you for the message, this may be useful for other Pleskians.
nice content, i tried it works !
This is out of date by a long shot, even though it says you updated it a month ago. Plesk 7.4.7 uses mcrypt-1.0.3 when installing via pecl:
Also, your instruction assumes the user uses apache2, when this is a bad assumption. I use nginx, because Apache is old and slow and limited. Corrections:
@Ryan Johnson
Thank you for your comment, I have updated the article accordingly.
On the 2nd line for CentOS
yum install --enablerepo=epel -y plesk-php72-devel gcc libmcrypt-devel
... you need to add the "make" library well in order to be able to compile.
Hello Webbing
"make" is included in the minimal CentOS installation, for example: https://gist.github.com/ozuma/552276c5d8e38b72f91d
I've also verified it on a test server.
Ivan Postnikov apparently not if you are installing it on CentOS 8.2. I ran into this issue last week...
Webbing
Thank you for the clarification.
I've updated the article with "make" installation. If make is already present, it will be updated.
BTW, on a test server, I have CentOS 8.1.1911 and "make" was present =)
Thanks!
Hi everyone,
When i try to do
"echo 'extension=mcrypt.so' > /opt/plesk/php/7.2/etc/php.d/mcrypt.ini" or "sudo cho 'extension=mcrypt.so' > /opt/plesk/php/7.2/etc/php.d/mcrypt.ini"
i get this problem:
"-bash: /opt/plesk/php/7.4/etc/php.d/mcrypt.ini: Permission denied" does anyone have the solution ?
i'm losing my mind to insta mcrypt :(
im using ubuntu, which i can't install php-mcrypt.
there's no tutorial about php-mcrypt on Ubuntu
Please sign in to leave a comment.