Jens Segers on Oct 19 2015

Installing PHP 5.6 and Mcrypt on Mac OSX

Years ago I wrote a blog post on how to install the PHP mcrypt extension on OSX. But times change, and here's how you do it, for real.

Disclaimer: I personally use Vagrant instead of setting up PHP and Nginx on my local machine. This allows me to quickly switch between completely different development environments. But if you prefer to have PHP and Apache running locally, then this post is what you are looking for.

First things first, you need Homebrew, seriously. It is a package manager that simplifies the installation of software on OSX. Install it by either going to their website and follow the installation instructions or just execute this in your terminal:

ruby -e "$(curl -fsSL"

Because Homebrew is going to build a couple of things, you are going to need the Xcode command line tools as well:

xcode-select --install

Now simply install php56 and php56-mcrypt using Brew with this simple command:

brew install php56 php56-mcrypt

All that is left now is to tell Apache to use this new PHP version by editing your /etc/apache2/httpd.conf file. Search for the line that starts with LoadModule php5_module and change it to this:

LoadModule php5_module /usr/local/opt/php56/libexec/apache2/

Now restart your apache using sudo apachectl restart and you're good to go!


igordla 3 years ago

After searching in many websites. Your post saved my bacon. So, thanks!

saravm2h 3 years ago

After hours of searching, your blog helped me fix it! Thank you so much!

Adam 3 years ago

Oh my gosh, thank you. Didn't know about this config option.

fusco 3 years ago

I have an error with 'brew install php56 php56-mrcrypt'

albertovasquez 2 years ago

@fusco brew install homebrew/php/php56 homebrew/php/php56-mcrypt

daniel 2 years ago

how about nginx ?

dsff 1 year ago


Mir Adnan 1 year ago

How about PHP 7.1?

EllMitnex 1 month ago

Viagra Professionnel Cheap 25 Mg Viagra Price Osu Levitra En France generic cialis from india Where Can I Buy Omifin Cvs Pharmacy Price For Cialis Discount Online Real Hydrochlorothiazide Hypertension Get Drugs Overseas