Skip to content

Instantly share code, notes, and snippets.

@teroyks
Last active June 6, 2021 19:49
Show Gist options
  • Save teroyks/e0d271e6720eda692456 to your computer and use it in GitHub Desktop.
Save teroyks/e0d271e6720eda692456 to your computer and use it in GitHub Desktop.
Add PHP mcrypt extension on Mac OS X with Homebrew

You can install the mcrypt PHP extension with homebrew and use it with the standard PHP installation that comes with OS X.

Install mcrypt:

brew install mcrypt

Install the php extension -- this installs the whole php 5.5, but you can still use the system-provided one by default Note: install the version compatible with whatever your OS X PHP version currently is (check with php -v)

brew install homebrew/php/php55-mcrypt

The mcrypt shared library should now be installed in /usr/local/Cellar/php55-mcrypt/5.5.30/mcrypt.so.

The PHP settings file is /private/etc/php.ini. If you don't have said file, copy contents from php.ini.default in the same directory as your php.ini.

Find the Dynamic Extensions section of the php.ini file and add the following line to it:

extension=/usr/local/Cellar/php55-mcrypt/5.5.30/mcrypt.so

After this, you should have mcrypt installed and enabled in PHP (check with php -m -- mcrypt should be listed among the modules.

@gagarine
Copy link

gagarine commented Feb 3, 2019

I had so many problem with mcyrpt than I switched to macports after years of using brew.

With macports:
sudo port install php71-mcrypt

and it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment