Jie Ma bio photo

Jie Ma

web developer, freelance photographer

Twitter LinkedIn Instagram Github Weibo Flickr

Install Mcrypt on Mac by Homebrew

Recently I setup Laravel enviroment on my Macbook, when I create project or run php artisan, it always prompts Mcrypt PHP extension required. error for me. Becuase I am using vagrant homestead for Laravel development, I can homestead ssh to run commands, but I think it’s better and convenience for me to install Mcrypt on my local enviroment. Then I did some reseach, and setup Mcrypt with mac native PHP.

###There are three ways I found:

  • Manually complie Mcrypt source and install
  • Using Homebrew to install
  • Using MAMP Mcrypt

For my requirement, I think homebrew is the best way for me.

###First Install autoconf which is needed when homebrew compling Mcrypt

brew install autoconf

###Homebrew tap Homebrew dupes, versions, and homebrew-php tap

brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php

###Install php55 or php56

brew install php55

or

brew install php56

###PHP Mcrypt

brew install php55-mcrypt

or

brew install php56-mcrypt

#Last add mcrypt extension into /etc/php.ini. You can find path using brew info php55-mcrypt, eg.

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