0

First of all, I was born and raised using a PC so I'm kind of new to Mac. I was hoping if someone can help me out. I'm using Catalina and trying to get the PHP extension mcrypt installed. I've been trying to use homebrew and I'm seriously stuck. I've researched this like crazy and all the forums are years old or using Ubuntu. I realize that mcrypt is deprecated but Laravel requires it so here I am.

I installed PHP 7.4 using homebrew. I had to add a couple of path lines to my ~/.zshrc file because the terminal kept saying PHP was 7.3. I run brew install mcrypt and it downloads and "Pours" into /usr/local/Cellar/mcrypt/2.6.8. I try to update my 7.4 php.ini file with a dynamic library path. So I try adding extension=/usr/local/Cellar/php/7.4.5_2/pecl/20190902/mcrypt.so to the ini for PHP. I restart apache and I get:

Warning: PHP Startup: Unable to load dynamic library '/usr/local/Cellar/php/7.4.5_2/pecl/20190902/mcrypt.so' (tried: /usr/local/Cellar/php/7.4.5_2/pecl/20190902/mcrypt.so (dlopen(/usr/local/Cellar/php/7.4.5_2/pecl/20190902/mcrypt.so, 9): image not found), /usr/local/lib/php/pecl/20190902//usr/local/Cellar/php/7.4.5_2/pecl/20190902/mcrypt.so.so (dlopen(/usr/local/lib/php/pecl/20190902//usr/local/Cellar/php/7.4.5_2/pecl/20190902/mcrypt.so.so, 9): image not found)) in Unknown on line 0

I have no idea where to go from here. Anyone have a tip?

Thanks!

4 Answers 4

0

Don't know if this is the right way but I got it to work: https://stackoverflow.com/questions/54028143/mcrypt-php-extension-required-on-mac-os-x-mojave

The answer on there was to pretty much remove any link for mcrypt and then re-link it. I had issues with the autoconf which required some file permissions tweaking (sudo wasn't working). That answer was here. https://stackoverflow.com/questions/16844826/error-when-trying-to-brew-link-autoconf

This was such a nightmare but that worked for me.

0

This means the referenced extension is not found in the given directory. So check that the reference is right by navigating to the provided directory:

cd /usr/local/Cellar/

you might have sub-directories: php, [email protected], [email protected] depending on the installed versions.

choose the version you want to use and navigate to its' subdirectory: eg for php7.4,

cd 7.4/7.4.9/pecl/20190902/

and you should see the extension.

so your full path becomes:

/usr/local/Cellar/[email protected]/7.4.16/pecl/20190902/xdebug.so 

Next, find your php.ini file:

php --ini

navigate to the line that starts with Loaded Configuration File, open the php.ini file and edit this line

 /usr/local/Cellar/php/7.4.9/pecl/20190902/xdebug.so

to point to the correct path, in this case:

/usr/local/Cellar/[email protected]/7.4.16/pecl/20190902/xdebug.so 

please note that the minor version 7.4.16 might differ depending on the version installed.

0

These simple steps will also work for php 7.4 or newer

brew install mcrypt
pecl install mcrypt-1.0.4  


php --ini

brew services restart [email protected] 


php -m | grep 'mcrypt' 

Cheers !

0

I have tested in macOS Big Sur Version 11.7.6, php version 7.4.33, nginx version: nginx/1.25.1

Open This link https://pecl.php.net/package/mcrypt download latest version.

Extract download .tgz (For example mcrypt-1.0.6.tgz)

Open Your terminal go to download folder

cd mcrypt-1.0.6/mcrypt-1.0.6

phpize && ./configure && make && sudo make install


php -i | grep "Loaded Configuration File"

Output will be something like bellow. Loaded Configuration File => /usr/local/etc/php/7.4/php.ini

Open /usr/local/etc/php/7.4/php.ini

Add extension=mcrypt.so

Restart Your PHP

brew services restart [email protected]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .