OS: macOS 11 (big sur)
Homebrew: 2.5.12
PEAR Version: 1.10.12
I just upgraded the php on my mac from php7.1 to php7.4 with homebrew (brew install [email protected]).
Then, when I try to install mcrypt extension, I got the error:
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
ERROR: `/private/tmp/pear/install/mcrypt/configure --with-php-config=/usr/local/homebrew/opt/[email protected]/bin/php-config --with-mcrypt' failed
Here is what I did:
- brew isntall mcrypt
- install the pecl
- sudo pecl install mcrypt — The error goes here.
What I tried:
-
Located the mcrypt.h and put manually the file to the several locations (based on the php-config), not work.
-
Cleaned the brew and reinstall/relink the mcrypt(libmcrypt), not work.
-
Removed the legacy mcrypt files of the old brew version.
4
Answers
The problem here is the configure command can’t find the libmcrypt installed by homebrew
You can
Download the source code of mcrypt-1.0.4, then cd in the folder
run "phpize"
run "./configure –with-mcrypt=/opt/homebrew/Cellar/mcrypt/2.6.8", you can change the path here with your path for homebrew lib
run "make && make install"
add extension=mcrypt.so to your config file
ps: Use
php -i | grep "Loaded Configuration File"
to locate your php configure fileI ran into the same problem. So after installing libmcrypt with
brew install mcrypt
it seems like configure is not able to resolve the path to mcrypt.h automatically. It also does not work to specify the CPPFLAGS or giving the homebrew include path.But I found a solution that works for me by giving pecl the install location of mcrypt in the Homebrew Cellar. This is what the following code does automatically:
pecl install mcrypt <<<"$(ls -d $(brew --prefix)/Cellar/mcrypt/* | tail -1)"
in case of an error on macOS use the complete path in php.ini like:
if you using brew try this :
1.Unistall existing php then Install shivammathur/php
add shivammathur php
change php version with you needed (5.6 or 7.2 or 7.4 or 8.1 or next version)
2.Install shivammathur/extensions it s will add extension to php
then
then you install mcrypt with same version as php version
then restart httpd
Ref :
https://github.com/shivammathur/homebrew-php
https://github.com/shivammathur/homebrew-extensions