Considering you are here, I can assume you are a desperate folk looking for a possible solution to make built-in MAMP work perfectly using the default packages that comes with clean Snow Leopard installation. Trust me, I was feeling like you are now a few hours before I start this post.
Here you’ll see how to enable Apache2, turn PHP 5.3 available on server and also install missing PECL extensions of PHP, such as Imagick (ImageMagick), Xdebug, APC and Memcache.
Before we start I would assume you have Xcode and Homebrew installed.
Xcode 4 is paid, but you can install 3rd version by using the DVD that came with your Mac. It’s free! =)
Enabling Web Sharing (Web Server)
This is the first step to be done, which is turn Apache2 ON to make your machine responds to HTTP requests. To do that, open your System Preferences > Sharing. Then, turn on Web Sharing:

That’s it. You already have Apache2 running on your system. Now let’s enable PHP.
Enabling PHP on Web Server
To enable PHP in Apache, you have to open /private/etc/apache2/httpd.conf file with root privileges. Locate the line:
#LoadModule php5_module libexec/apache2/libphp5.so
Remove the #.
Now, locate the line:
DirectoryIndex index.html
Edit it to be:
DirectoryIndex index.php index.html
Now, save and exit.
Go to System Preferences > Sharing again and turn Web Sharing OFF then ON.
Testing Apache2 + PHP integration
You can use Terminal for this one. We are going to create a phpinfo file, which displays all PHP configuration that is exposed to user land. In Terminal:
$ cd ~/Sites
$ vim info.php
Now press I (enable Insert mode in VIm) and type:
Now press Esc, then :wq <Enter>
Esc leaves Insert mode of VIm and enter in File manipulation mode. W means write and Q means quit.
Access your page, it should be something similar to http://localhost/~<username>/info.php
You should see a page similar to this one:
If you scroll down, you will see at Date extension a big warning telling you haven’t chosen a locale of your server. We are going to fix this now. On Terminal, type this:
$ sudo cp /private/etc/php.ini.default /private/etc/php.ini
Now open this file for edit. Locate this line:
Remove the ; and place whatever timezone you are at. Here is the list of available timezones. In my case, I’m in America/Sao_Paulo.
Save the file and reload the server (go to System Preferences > Sharing, then disable and enable Web Sharing. Next time I’ll now explain again. =P). Now refresh the info page and the warning disappeared.
It is now time to install missing extensions on PHP.
Compiling APC on PHP
If you are familiar with PHP from other environments, you may think it is simply do a pecl install. The problem is that Snow Leopard doesn’t come with pecl or pear available by default. While pear is possible to be installed manually, pecl isn’t. So we need to make the everything the hard way.
Download the latest stable APC package available at: http://pecl.php.net/package/APC
Decompress the folder.
Install required packages for APC. That’s where Homebrew comes to rescue us.
Go to your Terminal and type:
It should install PCRE dependency. As soon as it finishes, we are allowed to continue to the next step.
Go inside of decompressed folder and on Terminal run these commands:
$ phpize
$ CFLAGS='-arch x86_64' ./configure
$ make
$ sudo make install
Please remember these 4 commands. We will use them to compile other extensions.
Now we need to enable the APC on PHP. Open /private/etc/php.ini in edit mode.
Locate a similar line and add this:
extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/apc.so
Save file and reload your server. Info should not display that APC is correctly configured!
Compiling Memcache on PHP
We are going to make the same process that we did with APC.
First download the latest stable package available at: http://pecl.php.net/package/memcache
Here are the steps I’ve done on my personal machine:
$ mv ~/Downloads/memcache-* ~/src
$ cd ~/src
$ tar xvf memcache-*
$ cd memcache-*
$ phpize
$ CFLAGS='-arch x86_64' ./configure
$ make
$ sudo make install
Now I opened again the /private/etc/php.ini file, located the apc.so line and added on the next line:
extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/memcache.so
Restarting the web server, my info now displays the Memcache extension loaded on PHP!
Compiling Xdebug on PHP
I followed the same steps that I did with Memcache, grabbing the latest stable package available at: http://pecl.php.net/package/xdebug
Enabling it is a bit different. I opened the /private/etc/php.ini file and added at the end of it:
[xdebug]
zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
xdebug.file_link_format="txmt://open?url=file://%f&line=%1"
xdebug.remote_enable = On
;xdebug.remote_handler = 'dbgp'
;xdebug.remote_handler = 'gdb'
;xdebug.remote_mode = jit
xdebug.remote_autostart = 1
Reloaded my server and voilà! It worked!
Compiling Imagick on PHP
Imagick relies on ImageMagick in order to work. Again we ask help for Homebrew to save our lives.
$ sudo brew install imagemagick
I will install a couple of dependencies, but at the end we’ll have ImageMagick working. Now we can get back to our tedious work of phpize, configure, make, make install…
Grab the latest stable package available at: http://pecl.php.net/package/imagick
Now, execute the commands:
$ mv ~/Downloads/imagick-* ~/src
$ cd ~/src
$ tar xvf imagick-*
$ cd imagick-*
$ phpize
$ CFLAGS='-arch x86_64' ./configure
$ make
$ sudo make install
Finally, open the /private/etc/php.ini file, located the memcache.so line and added on the next line:
extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/imagick.so
Reload your server and have fun! =)