Bobcares

Let’s enable PHP mcrypt extension in the server

by | Oct 5, 2019

My Laravel based project shows up error “Mcrypt PHP extension required.” Can you fix it please?

That was a recent support request that we received in our helpdesk for our Server Management Services.

The PHP-mcrypt extension uses advanced algorithms for cryptography. It helps to encrypt passwords as well as data.

Today, let’s see how our Support Engineers enable PHP mcrypt extension in servers.

 

What is the mcrypt extension?

Basically, mcrypt is a file encryption tool that uses advanced algorithms like AES, TripleDES and so on.

The Mcrypt extension is an interface to encrypt the Mcrypt cryptographic library. This extension enables PHP code to use mcrypt.

Earlier this extension was available in PHP. But for PHP 7.2+ and higher, the mcrypt extension is available only in the PECL repository. PHP 7.2 version and above uses libsodium as a cryptography library. Some developers even make use of the PHPSecLib/mcrypt_compat from Github in their code to make things easier.

On the whole, when your application complains about the Mcrypt extension, it is always worth checking the PHP version on the server.

 

How to install mcrypt extension?

PHP-mcrypt extension can be easily enabled in any server. Our Dedicated Engineers with expertise over a decade enables mcrypt for our customers. Now let’s discuss how we do it.

 

1. In Linux Servers

Initially, our Support Team verifies if the server has a mcrypt extension.

To check this, we use the command,

php -i | grep mcrypt

If there is no mcrypt extension, we install it. Usually, Linux servers have easy install tools like, yum and apt-get that eases the installation process.

For instance, in a CentOS server we use the command:

yum install php-mcrypt

And for a Debian/Ubuntu server we use the command:

apt-get install phpxx-mcrypt

Thus we ensure the successful installation of mcrypt extensions in the server.

Finally, we restart the webserver to update the changes.

In servers with PHP version 7.2+, mcrypt is not available with it. So, first we install the mcrypt dependencies using the following command:

apt-get -y install gcc make autoconf libc-dev pkg-config
apt-get -y install php7.2-dev
apt-get -y install libmcrypt-dev

And to install mcrypt from PECL we use the command:

pecl install --nodeps mcrypt-snapshot

Further, we set the default prefix, edit the PHP configuration and restart service using:

sudo bash -c "echo extension=mcrypt.so > /etc/phpxx/conf.d/mcrypt.ini"
sudo service php-fpm restart

That completes the installation of mcrypt on the servers.

Now let’s discuss the same in the Windows server.

 

2. Windows Server

Usually, in the Windows server, there are two ways to enable PHP-mcrypt extensions. That is manual edits the php.ini file or enable mcrypt via a control panel on the server.

So, if the server has a control panel, we enable the PHP extension from it. We access the configuration area of the panel and enable the mcrypt extension from it.

For instance, the PHP settings in Plesk appear as:

In case, if there is no control panel, our Support Engineers manually edit the php.ini file.

By default, php.ini is the main PHP configuration file. We open it and check for the mcrypt extension. We uncomment the line,

extension=php_mcrypt.dll

Finally, we save the file and restart the webserver. This shows up Mcrypt on the phpinfo page of the website.

 

[Having difficulty in enabling PHP-mcrypt extension? – We’ll help you.]

 

Conclusion

In short, up until the PHP7.2 version, PHP mcrypt extension enables the use of advanced algorithms for cryptography. Today, we saw how our Support Engineers enabled PHP-mcrypt in various server platforms.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

4 Comments

    • Sijin George

      Thank you for the information. I have updated the content.

      Reply
  1. Naoufal Afailal

    Is the mcrypt extension mandatory in wordpress?

    Reply
    • Hiba Razak

      No, mcrypt is an optional extension.It is a replacement for the popular Unix crypt command.

      Reply

Submit a Comment

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

Never again lose customers to poor
server speed! Let us help you.