It’s a very common issue that PHP scripts using mcrypt will not work in out of the box installation of PHP. Following are instructions for installation of php-mcrypt on CentOS 7.
In order to install php-mcrypt and resolve the issue with mcrypt support in PHP, we’ll first need to enable EPEL repository in our RHEL/CentOS 7 64 Bit install. This is because Epel project is not a part of RHEL/CentOS by default.
Note: EPEL (Extra Packages for Enterprise Linux) is an open source community based repository project that provides quality add-on software packages for Linux distribution including RHEL (Red Hat Enterprise Linux), CentOS, and Scientific Linux.
Login as root and run following commands in your secure shell client:
rpm -ivh epel-release-7-2.noarch.rpm
Note that epel-release-7-2.noarch.rpm may not be the latest available package – it’s the latest at the time of writing this blog post. So you may need to adjust it to the latest available version. Easiest way to do so is visiting: http://dl.fedoraproject.org/pub/epel/7/x86_64/e/ and search for the word: epel-release… , then mark down the latest version and amend the commands above. It’s apparently possible to install the latest version automatically by using following instructions, but it’s not something I’ve tested (if you do let me know the outcome).
Now that we have added EPEL, let’s follow by installing php-mcrypt via YUM:
yum install php-mcrypt*
Because changes to PHP are not reflected until webserver is restarted, reboot your Apache first:
service httpd restart
Or if you’re using NGINX, restart it using:
systemctl restart nginx
And we’re done!