mcrypt is an amazingly useful php extension you may not be able to live without for long. Here is how to set it up on CentOS 6.x.
Step 1. Make yourself comfortable in a temp directory somewhere on your system:
cd /tmp/
For the following steps, you need to be root, so will either have to prefix commands with sudo, or switch to root; for example on AWS, this is done using:
sudo su
Step 2. Get yourself the rpms to set up repositories:
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
and install:
rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
Step 3. Run an update based on the newly set up repositories (just in case):
yum update
Step 4. Install the php-mcrypt module:
yum install php-mcrypt*
Step 5. The mcrypt module needs to be enabled in its own mcrypt.ini file (in the modules directory of your php installation):
extension=mcrypt.so
as well as inside of your php.ini file (php must be compiled with support for this module):
extension=mcrypt.so
If, at this point, you are wondering where the .ini files are hiding, you can command your php server to disclose their location using:
php-fpm -i
Step 6. Once you ensured that the module will be loaded, restart your server:
service nginx restart; service php-fpm restart
Done.