Finally figured how to compile things on my Mac to support IMAP-SSL.  MAMP does not have this compiled in by default.  Since I want to do local development without having to upload to a Linux server to test every single time, getting MAMP to support IMAP-SSL was critical.
IMAP-SSL is used for things like Gmail access.

It was not easy to compile PHP5.3.2 on MAMP. First of all, you need to download httpd2.0.63 and PHP5.3.2. (I’m using MAMP 1.9 and Mac OSX 10.6.2)

STEP 1: Backup original MAMP

Backup your MAMP Applicaiton first in case things go wrong.
It is in /Application/MAMP

STEP 2: Download source files

Download software packages and save in a “source download” folder somewhere (I used ~/src/)

  • HTTPD-2.0.63
  • PHP-5.3.2  (

STEP 3: Build apache httpd

This step is needed to provide MAMP some build & include files from Apache httpd.

% tar jxvf httpd-2.0.63.tar.bz2
% cd httpd-2.0.63

Now you need to edit srclib/apr/include/apr.h like “#define APR_HAS_SENDFILE 0″ after run configure because get an error.

./configure \
--prefix=/tmp/httpd-2.0.63 \
--with-php \
--with-mysql \
--enable-rewrite \
--enable-speling \
--enable-ssl \
--enable-deflate \
--enable-mods-shared=all \
--with-included-apr \
--enable-so \
--enable-proxy \
--enable-proxy_connect \
--enable-proxy_ftp \
--enable-echo \
--enable-file_cache \
--enable-mem_cache \
--enable-bucketeer \
--enable-cache \
--enable-case_filter \
--enable-case_filter_in \
--enable-cgid \
--enable-charset_lite \
--enable-disk_cache \

The configuration settings enable the default modules that MAMP builds into their application. This will let you use the MAMP interface to turn on/off the various modules as needed (because MAMP UI controls HTTPD.CONF file).

% make
% make install
% cd /tmp/httpd-2.0.63
% cp -r build /Application/MAMP/Library/
% cp -r include /Application/MAMP/Library/
% cp -r modules/mod_* /Applications/MAMP/Library/modules/

STEP 4: Build PHP-5.3.2

Step 4a

% tar jxvf php-5.3.2
% cd php-5.3.2

The below configuration file uses a combination of MAMP-specific folders (/Applications/MAMP/) and Apple-provided files (/usr/).
For those that decide to use DarwinPorts to get some components, these will be located in (/opt/local/).  This is a way to avoid having to go to different websites to download specific modules.

My previous MAMP version was 1.8.? and had a PHP configuration for T1LIB (–with-t1lib=/Applications/MAMP/Library).  I removed T1LIB b/c not installed on MACOSX.

./configure \
--prefix=/Applications/MAMP/bin/php5.3 \
--exec-prefix=/Applications/MAMP/bin/php5.3 \
--sysconfdir=/Applications/MAMP/conf/php5.3 \
--with-config-file-path=/Applications/MAMP/conf/php5.3 \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--with-apxs2=/Applications/MAMP/Library/bin/apxs \
--enable-cli \
--with-libxml-dir=/Applications/MAMP/Library \
--with-openssl=/usr \
--with-kerberos=/usr \
--with-zlib=/usr \
--enable-bcmath \
--with-bz2=/usr \
--enable-calendar \
--with-curl=/Applications/MAMP/Library \
--enable-exif \
--enable-ftp \
--with-gd \
--with-jpeg-dir=/usr/local/libjpeg \
--with-png-dir=/usr/local/libpng \
--enable-gd-native-ttf \
--with-ldap=/usr \
--with-ldap-sasl=/usr \
--enable-mbstring=all \
--enable-mbregex \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-mysql-sock=/tmp/mysql.sock \
--with-iodbc=/usr \
--enable-shmop \
--with-snmp=/usr \
--enable-soap \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--with-xmlrpc \
--with-iconv-dir=/usr \
--with-xsl=/usr \
--with-pcre-regex \
--with-imap \
--with-imap-ssl \
--with-mcrypt \
--with-mhash \
--with-freetype-dir=/usr/X11 \
--enable-zend-multibyte \
--with-gettext \

Step 4b

NOTE: You may need to install some packages before compile PHP for some components that are not included.
You can use DarwinPorts, or download individually.

Manual method ==>
MacPorts method ==>

Instructions for JPEG & PNG missing files (

libjpeg, libpng, libmcrypt, IMAP c-client, libintl, gettext, libxml

Step 4c

Now, we need to work around a bug with inconv linking. Luckily, Apple provides a patch. Either copy the text of that patch and save it as a file or download it here.

curl -O
patch -p1 < iconv.patch

Step 4d

Now that iconv will link properly, continue with our make.

% make -j3
% make install

Step 4e

After you have finished making PHP, it should have copied LIBPHP5.SO to your “apache” location. is located where you set –prefix for apache.
It’s needed to copy to /Applications/MAMP/Library/modules.

SIDE NOTE: May need to build IMAP-SSL individually.

I am not sure if this step was needed, but I also compiled a separate IMAP.SO module (which may already be build during the PHP build).
Compile IMAP first    (

cd imap-2007e/
make osx EXTRACFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp"
sudo cp c-client/*.h /opt/local/include/
sudo cp c-client/*.c /opt/local/lib/
sudo cp c-client/c-client.a /opt/local/lib/libc-client.a

Reroute to MAMP directory

sudo cp c-client/*.h /opt/local/include/
sudo cp c-client/*.c /opt/local/lib/
sudo cp c-client/c-client.a /opt/local/lib/libc-client.a

An alternate method is to go into PHP source file into ext/imap/ and then you can compile just the module.
Use below to CONFIGURE custom IMAP.SO compile

./configure --with-php-config=/Applications/MAMP/bin/php5.3/bin/php-config --with-imap=/usr/local --with-kerberos --with-imap-ssl=/usr

Reference Links

Original IMAP-SSL problem on MAMP