Fatal error: Call to undefined function mcrypt_encrypt() – Solved

While setting up a php project on CentOS 6, I came across an error   “Fatal error: Call to undefined function mcrypt_encrypt()”.

I thought mcrypt is not installed and that should be an easy fix.  Just a quick “yum install php-mcrypt”.  Nope.  It was already installed. After digging around for a while, installing, uninstalling, rebooting etc, I checked a config file /etc/php.d/mcrypt.ini.

Its contents were

; Enable mcrypt extension module
extension=module.so

This is incorrect. I changed it to

; Enable mcrypt extension module
extension=mcrypt.so

Then after restarted httpd the problem went away.  It appears that the php-mcrypt rpm, at least as of php-mcrypt-5.3.3-1.el6.rf.i686, incorrectly creates the mcrypt.ini file.

I hope this saves time for some of you.