PHP ZIP Extension for MAMP
Do you use MAMP as a web development testing environment on your Mac?
Do you need the PHP ZIP extension for dealing with archive files?
Are you running Mac OS X 10.6 Snow Leopard?
I do, and found making these tools play nice together to be far harder than it should have. If you need to fix a similar setup, here are the steps that finally worked for me (on Mac OS X 10.6.4 with MAMP 1.9):
- Install XCode if you don’t already have it (we’re going to be doing a bit of compiling).
- Download the MAMP source code components (available towards the bottom of the page).
- When the MAMP source code package opens, go into the MAMP_src folder and double-click the php-5.3.2.tar.gz file (if you are using a different version of PHP, replace 5.3.2 with your actual version number).
- You should now have a php-5.3.2 folder in your Downloads folder. Open up Terminal and cd to ~/Downloads/php-5.3.2.:
cd ~/Downloads/php-5.3.2/ - Install the pcre.h header file (we need it to compile the extension):
sudo cp ext/pcre/pcrelib/pcre.h /usr/include/php/ext/pcre/ - Configure PHP for i386 architecture:
CFLAGS="-arch i386" ./configure - Configure the ZIP extension for i386 architecture:
cd ext/zip; CFLAGS="-arch i386" ./configure - Build the extension:
make - Install the extension:
cp modules/zip.so /Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/ - Enable the extension by opening /Applications/MAMP/conf/php5.3/php.ini and appending the following line:
extension=zip.so - Remove the pcre.h header file we installed earlier, we don’t need it anymore.
- Restart MAMP. If everything worked properly, you’ll be able to goto http://localhost/MAMP, click on phpInfo, and see zip in the list of enabled extensions.









November 19th, 2010 at 3:59 am
Hi, I’ve tried to use this guide but I get “no such file or directory” when I use:
cd ext/zip; CFLAGS=”-arch i386″ ./configure
I’m a bit of a noob at all this terminal stuff so It’s probably something really stupid I’ve done wrong. I would really appreciate an email with a few hints. Thanks in advance.
November 19th, 2010 at 5:46 pm
Are you still in the php-5.3.2 directory when you run that command? If you are, type “ls” to list the files and directories. There should be a directory named”ext”. You can then move into it by typing “cd ext”. Type “ls” again; you should see a directory named “zip”. Typing “cd zip” should move you into it. If this doesn’t work, let me know what error messages you get.
November 20th, 2010 at 2:21 am
Hi, I have the directory ext/zip but it won’t let me ‘configure’ it. Here’s the terminal text (added line breaks to make it readable):
andys-mac-pro:php-5.3.2 Andy$
cd ext/zip; CFLAGS=”-arch i386″ ./configure
-bash: ./configure: No such file or directory
andys-mac-pro:zip Andy$ ls
CREDITS config.m4 examples php_zip.c tests
TODO config.w32 lib php_zip.h zip_stream.c
andys-mac-pro:zip Andy$
CFLAGS=”-arch i386″ ./configure
-bash: ./configure: No such file or directory
All the other steps work fine but it just fails on this one. I’m running 10.6.4 and MAMP 1.9 and the latest XCode.
November 21st, 2010 at 11:21 am
So do you have any ideas what’s up?
Thanks in advance!
November 21st, 2010 at 4:57 pm
Not sure why, but it sounds like the first “CFLAGS=”-arch i386″ ./configure” line is failing at some point, or at least not creating the ZIP extension’s configure script.
November 22nd, 2010 at 1:59 am
Any ideas how to sort it?
January 17th, 2011 at 2:23 pm
Awesome explanation.
I would’ve never figured that out all by myself.
Thx
August 23rd, 2011 at 3:00 am
Hi. I’ve got the same problem as Andy Marshall. The configure script is missing from zip folder. Any idea how to get it created?
December 3rd, 2011 at 6:53 pm
Readers should probably look very closely at the statistics geoff put in there. Because this is a strategy that I employ effectively to make a quick 30% on margin simply by shorting the stock the day before the B.D.’s are released. I will generally hedge with calls out of the money in case market is positive.