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.

@arjus
Copy link

arjus commented May 2, 2017

+1
Thank You!

@emeraldhieu
Copy link

I see no mcrypt.so at "/usr/local/Cellar/mcrypt/2.6.8/".

drwxr-xr-x 14 hieugioi admin 448 Apr 29 18:29 .
drwxr-xr-x 3 hieugioi admin 96 Apr 27 17:19 ..
drwxr-xr-x 3 hieugioi admin 96 Nov 17 2008 .brew
-rw-r--r-- 1 hieugioi admin 485 Nov 17 2008 AUTHORS
-rw-r--r-- 1 hieugioi admin 35147 Nov 17 2008 COPYING
-rw-r--r-- 1 hieugioi admin 18832 Nov 17 2008 ChangeLog
-rw-r--r-- 1 hieugioi admin 645 Apr 27 17:19 INSTALL_RECEIPT.json
-rw-r--r-- 1 hieugioi admin 25592 Nov 17 2008 NEWS
-rw-r--r-- 1 hieugioi admin 595 Nov 17 2008 README
-rw-r--r-- 1 hieugioi admin 98 Nov 17 2008 TODO
drwxr-xr-x 5 hieugioi admin 160 Apr 27 17:19 bin
drwxr-xr-x 4 hieugioi admin 128 Nov 17 2008 include
drwxr-xr-x 5 hieugioi admin 160 Nov 17 2008 lib
drwxr-xr-x 4 hieugioi admin 128 Nov 17 2008 share

@sicaboy
Copy link

sicaboy commented May 1, 2018

No available formula

@SiluntKnight
Copy link

I found following this guide to help:

https://coolestguidesontheplanet.com/install-mcrypt-for-php-on-mac-osx-10-10-yosemite-for-a-development-server/

Just replace the php version with the version you are running php -v

This works with High Sierra

@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