While compiling PHP from source on CentOS server, we get the error below:
checking for mcrypt support... yes configure: error: mcrypt.h not found. Please reinstall libmcrypt.
The root of the problem is we’ve enabled this option –with-mcrypt.
./configure --prefix=/usr/local/php7 \ --with-config-file-path=/usr/local/php7/etc \ --with-config-file-scan-dir=/usr/local/php7/etc/conf.d \ --enable-bcmath \ ... --with-mcrypt \ --with-jpeg-dir
In this, we have to install the dependencies packages as follows:
sudo yum -y install libmcrypt-devel
# yum list installed | grep libmcrypt libmcrypt.x86_64 2.5.8-13.el7 @epel libmcrypt-devel.x86_64 2.5.8-13.el7 @epel
And then try to re-compile PHP from source and it should be able to compile this time.