Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot install mcrypt with homebrew and php7.4

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:

  1. brew isntall mcrypt
  2. install the pecl
  3. sudo pecl install mcrypt -- The error goes here.

What I tried:

  1. Located the mcrypt.h and put manually the file to the several locations (based on the php-config), not work.

  2. Cleaned the brew and reinstall/relink the mcrypt(libmcrypt), not work.

  3. Removed the legacy mcrypt files of the old brew version.

like image 257
zhangv Avatar asked Dec 01 '20 07:12

zhangv


People also ask

How do I enable mcrypt?

You can install Mcrypt from the PHP Source Tree as a module if you choose. Enable the module by adding: 'extension=mcrypt.so' to PHP. ini. Done!

Is mcrypt deprecated?

The mcrypt extension has been abandonware for nearly a decade now, and was also fairly complex to use. It has therefore been deprecated in favour of OpenSSL, where it will be removed from the core and into PECL in PHP 7.2.

How do I know if mcrypt is enabled?

You can also achieve this same screen by viewing a php file that has: phpinfo(); somewhere in the code. In this screen, simply search for the string "mcrypt support". If installed, you will see a box that says "enabled".


1 Answers

I 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)"

like image 109
OderWat Avatar answered Sep 22 '22 14:09

OderWat