skip to Main Content

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.

4

Answers


  1. The problem here is the configure command can’t find the libmcrypt installed by homebrew

    You can

    1. Download the source code of mcrypt-1.0.4, then cd in the folder

    2. run "phpize"

    3. run "./configure –with-mcrypt=/opt/homebrew/Cellar/mcrypt/2.6.8", you can change the path here with your path for homebrew lib

    4. run "make && make install"

    5. add extension=mcrypt.so to your config file

    ps: Use php -i | grep "Loaded Configuration File" to locate your php configure file

    Login or Signup to reply.
  2. 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)"

    Login or Signup to reply.
  3. in case of an error on macOS use the complete path in php.ini like:

    extension="/opt/homebrew/Cellar/php/8.1.9/pecl/20210902/mcrypt.so"
    
    Login or Signup to reply.
  4. if you using brew try this :

    1.Unistall existing php then Install shivammathur/php

    add shivammathur php

    brew tap shivammathur/php
    

    change php version with you needed (5.6 or 7.2 or 7.4 or 8.1 or next version)

    brew install shivammathur/php/[email protected]
    

    2.Install shivammathur/extensions it s will add extension to php
    then

    brew tap shivammathur/extensions
    
    brew install shivammathur/extensions/[email protected]
    

    then you install mcrypt with same version as php version

    brew install [email protected]
    

    then restart httpd

    brew services restart httpd
    

    Ref :

    https://github.com/shivammathur/homebrew-php

    https://github.com/shivammathur/homebrew-extensions

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search