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.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF