Enabling PHP's "Zip Extension" in MAMP
If you're involved in web development on the Mac, chances are you've seen or used MAMP before (especially if you're doing PHP development). It's a great platform and MAMP PRO is a great tool to quickly do things that get kind of tedious to handle via terminal. During my ongoing development of Heartbeat, I found myself needing PHP's zip extension and unfortunately, it doesn't come enabled by default with MAMP. After compiling PHP about 10 times and running into weird errors, I found an approach that worked for me. I know there are easier ways (PECL); however, it's not very reliable with MAMP and out of the 3-4 times that I've needed to install extensions with MAMP, utilizing PECL only worked once. This method seems fool-proof as far as I've seen.
1. Download MAMP's "Source" package, located here. If that link doesn't work, it should be linked at the bottom of this page: http://mamp.info/en/download.html
2. Open the archive and look for the PHP version that you're using (4 or 5) and unzip that archive. (I'm using 5 (everyone should be), so I unzipped that one.)
3. Open terminal and cd to the PHP directory that you just unzipped.
4. Run the following command in terminal: ./configure --prefix=/tmp/php
5. Wait for the configure script to finish and then run: export PATH=/tmp/php/bin:$PATH
6. Now, cd to the zip extension directory: cd ext/zip
7. Run: phpize
8. Run: ./configure
9. Wait for it to finish and then run: make
10. Wait for it to finish and then run: sudo make install -- (You'll need to type your administrative password.)
11. After it's done running, you'll see something like this:
Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20060613/
12. Copy the zip.so extension file from that directory to your PHP installation's extension directory:
cp /usr/lib/php/extensions/no-debug-non-zts-20060613/zip.so /Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20050922
13. Open up MAMP's PHP.ini file (Hint: In MAMP Pro, open up the MAMP Pro app, go to "File > Edit Template > PHP5 php.ini") and scroll down to where your extensions are listed and add the following on a new line: extension=zip.so
14. Save the file, restart Apache and your PHP Info page should reveal that the zip extension is now installed.
Saverio
blog comments powered by Disqus