Michael Gracie

Plugging mcrypt into PHP on macOS Sierra 10.12

We climbed up then down El Capitan, yet little changed. We’re still in the Sierras, and there’s still work to do.

The following instructions are for peeps a) developing on macOS Sierra 10.12, b) need mcrypt for their PHP development i.e. PHPMyAdmin and/or encrypting personally identifiable data before storage (unlike your health insurer, Yahoo! and/or pretty much every other knucklehead out there), and c) do not want to recompile PHP or run MAMP. Mcrypt will load dynamically with PHP after completing this tutorial.

We begin by acquiring the following stuffs …

1) libmcrypt-2.5.8, which you can find here; download by clicking the one of the two file links (author used “libmcrypt-2.5.8.tar.gz”);

2) PHP 5.6.24 source code, which is available here; [NOTE: you may someday update OS X beyond 10.12, and PHP may get updated along with it; the author used 10.12, and PHP 5.6.24 was included with that OS version. If necessary use php -v to check your version of PHP and then download the PHP source for that version.];

3) Xcode 8.0, which you can get from the App Store. You will also need the Command Line Tools (macOS 10.12) for Xcode, which you get by selecting “Xcode/Open Developer Tool/More Developer Tools…” from the Xcode menu, then logging into your Apple Developer account (yea you need one of those too); and

4) Homebrew ( which can be installed by typing ruby -e "$(curl -fsSL install/master/install)" at the command line.

But before we really wind up, let’s turn off System Integrity Protection (SIP):

  1. Click the Apple menu (upper left hand corner of your screen)
  2. Select Restart, then hold down the Command-R keys to boot into Recovery Mode
  3. Select the Utilities menu and then Terminal
  4. In Terminal, type csrutil disable and then hit return; then close Terminal
  5. Click the Apple menu and select Restart

NOTE: When you are done installing mcrypt, you can restart SIP by following the above steps while substituting csrutil enable in step 4.