Install PHP Mcrypt on CentOS


Install PHP Mcrypt on CentOS


The PHP module “Mcrypt” provides encryption and decryption using algorithms such as DES, TripleDES and Blowfish. You can read more about it on the official PHP Mcrypt page.

This is required by eCommerce systems such as Magento, however it’s not part of the standard RHEL / CentOS packaging.

CentOS 6 and 6.5 allow you to install PHP-mCrypt easily right after installing CentOS. The reason mCrypt is removed by default from version  7 is still unknown, but we’re going to show you how to re-enable it.

The php-mcrypt package is available (for CentOS, Scientific Linux, and Oracle Linux administrators) from the RPMforge repository and from the EPEL repository.


How to install mcrypt ?

First, add the repository. For example, to add EPEL:

# rpm -Uvh

Then, install the php-mcrypt module:

# yum install php-mcrypt

If you see this —-> its OK 🙂

yum install php-mcrypt.x86_64
oaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* atomic:
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php-mcrypt.x86_64 set to be updated
--> Processing Dependency: php-common = for package: php-mcrypt
--> Running transaction check
---> Package php-common.x86_64 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
Package                                                   Arch                                                  Version                                                          Repository                                             Size
php-common                                                x86_64                                                                                      atomic                                                1.0 M
replacing  php53-common.x86_64 5.3.3-13.el5_8
php-mcrypt                                                x86_64                                                                                      atomic                                                 48 k
Transaction Summary
Install       2 Package(s)
Upgrade       0 Package(s)
Total size: 1.1 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing     : php-common                                                                                                                                                                                                             1/3
warning: /etc/php.ini created as /etc/php.ini.rpmnew
Installing     : php-mcrypt                                                                                                                                                                                                             2/3
Erasing        : php53-common                                                                                                                                                                                                           3/3
php-common.x86_64                                                                                 php-mcrypt.x86_64
php53-common.x86_64 0:5.3.3-13.el5_8


* Recommended to restart Apache service:

service httpd restart


To check if installation was successful:

[root@sergeyb]# yum list installed | grep mcrypt


[root@sergeyb]# php -r "echo phpinfo();" | grep "^mcrypt"
mcrypt support => enabled
mcrypt.algorithms_dir => no value => no value
mcrypt.modes_dir => no value => no value


Good luck !