OpenSSL support in PHP under MAMP

I recently started using a Mac for web development (I don't love it but that's another story). At the recommendation of several friends I'm using MAMP instead of the native Apache, PHP, and MySQL; they said it was much easier to set up. Yesterday, I discovered that MAMP's PHP install does not come with the OpenSSL extension so, for example, you cannot visit HTTPS sites from within PHP. Searching the web revealed several posts from people with the same problem but no solutions. I have no idea why MAMP does not ship with the openssl extension but, it turns out, it is very easy to create yourself. Here's how:

1. Build the PHP openssl extension (or, if you are really lazy, just download the one I built).

Download PHP from I'm using MAMP 1.6 (haven't bothered to upgrade) which uses PHP 5.2.1 which, it turns out, does not build properly on MacOS X 10.5 Leopard. So I used PHP 5.2.5 instead which works fine; this is also the version that MAMP 1.7 uses. Newer versions of 5.2 would probably also work.

Using Terminal, extract, configure, and build PHP, specifically requesting a *shared* openssl library:

% tar -xzf php-5.2.5.tar.gz
% cd php-5.2.5
% ./configure --with-openssl=shared
% make

2. Install the PHP openssl extension

From the same directory in which you ran make:

cp modules/ /Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20050922/

The date in the final directory name will depend on which version of MAMP/PHP you have installed.

3. Edit /Applications/MAMP/conf/php5/php5.ini.

Search for lines that contain "extension=" and add the line

That's it!

openssl.so80.46 KB