Need Mcrypt for PHP on MAC – this way does work

Trying the PHP framework Laravel I found that the framework would not start without Mcrypt installed, the encryption library. After some research I realized that I’d have to build the LIB and this page gave very good instructions.

A few things need to be understood:

  • Your MAC PHP is likely at one version and the available LIB code is later; find the right archive.
  • When you build the LIB there will likely be non-fatal errors; it’s ok.
  • You only need the .SO file and nothing more for PHP.

My MAC’s php version is 5.3.15 BUT all the releases are not obvious on the PHP repository so you go to the archive on this site and find you major.minor version which for me is 5.3 at the snapshot page.

I created the mcrypt directory and put the libmcrypt-2.5.8.tar.gz and php5.3-201301231830.tar.gz files in the directory and untarred them as directed.

Then, using the build instructions for the lib and php, I built them.

In the end I had on disk the .SO which is what I was after located at /usr/lib/php/extensions/no-debug-non-zts-20090626/

I added to the end of the /private/etc/php.ini file the lineextension = /usr/lib/php/extensions/no-debug-non-zts-20090626/

Then I restarted Apache and ran phpinfo() in a skeletal file and found that mcrypt was now installed.

I checked the default page for Laravel and there it was.

Excellent instructions.

Leave a Reply

Your email address will not be published. Required fields are marked *