Steps to enable PHP mcrypt extension in Windows and Linux server

To use cryptography in PHP mcrypt extension, it needs an algorithm which should be advanced more than our expectation. Yes, it is essential to protect the data and password too. For this type of encryption, the tool called “mcrypt” is used with the partner algorithms like TripleDES and AES etc. The interface of Mcrypt extension is widely recognized for encrypting cryptography library for Mcrypt.

Most probably, it is not possible to run a mcrypt without a third runner. So, PHP code is the one which helps to run mcrypt. This gives an awesome work in all types of PHP versions but for some versions such as 7.2, it is recommended only to use in PECL repository.

Let’s see steps to install PHP mcrypt extension in two types of servers such as:
  1. Linux server
  2. Windows server
Linux server:

Before a start-up, check the mcrypt extension is installed in Linux server or not. It’s just a confirmation!

Here’s a command to cross-check the installation of mcrypt extension:

Code:
Php –i | grep mcrypt
After this command execution, check you get a message like “mcrypt extension installed already”. If you didn’t find installation then there is more number of tools to install it easier like apt-get and yum.

For example:

Below, you can see commands for few servers:



S.NO

SERVER NAME

COMMAND

1.​

CentOS​

yum install php-mcrypt​

2.​

Ubuntu/Debian​

apt-get install phpxx-mcrypt​


To get a successful installation of the mcrypt extension, it is must to apply the modifications by restarting the webserver.

For a server type of PHP 7.2+ use the below-mentioned command for execution:

Code:
apt-get -y install gcc make autoconf libc-dev pkg-config
apt-get -y install php7.2-dev
apt-get -y install libmcrypt-dev
PECL helps you to give a fine-touch of installation. Use the command to install mcrypt extension easier:

Code:
pecl install --nodeps mcrypt-snapshot
Finally, it is must process default prefix set up and make changes in the configuration of PHP. Make a move to restart the entire process!

Code:
sudo bash -c "echo extension=mcrypt.so > /etc/phpxx/conf.d/mcrypt.ini"
sudo service php-fpm restart
It’s over here for mcrypt extension installation in Linux server!

Windows server:

Here, the Windows server has a mechanism to install mcrypt extension in two choices such as:
  1. Using the server control panel to enable mcrypt
  2. Making few changes in the file php.ini
It doesn’t go for the long way to enable the extension of PHP. Go to the configuration panel and then do a wise choice of mcrypt extension enablement.

If you fail to enable mcrypt extension using the server control panel then uncomment the below command in php.ini:

Code:
extension=php_mcrypt.dll
Again all over here too! Give a webserver restart and don’t forget to save the changes before restarting the webserver.
Author
bhawanisingh
Views
16,352
First release
Last update
Rating
0.00 star(s) 0 ratings
Top