Oct 10 2010

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):

  1. Install XCode if you don’t already have it (we’re going to be doing a bit of compiling).
  2. Download the MAMP source code components (available towards the bottom of the page).
  3. 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).
  4. 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/
  5. 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/
  6. Configure PHP for i386 architecture:
    CFLAGS="-arch i386" ./configure
  7. Configure the ZIP extension for i386 architecture:
    cd ext/zip; CFLAGS="-arch i386" ./configure
  8. Build the extension:
    make
  9. Install the extension:
    cp modules/zip.so /Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/
  10. Enable the extension by opening /Applications/MAMP/conf/php5.3/php.ini and appending the following line:
    extension=zip.so
  11. Remove the pcre.h header file we installed earlier, we don’t need it anymore.
  12. 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.

Nov 23 2008

New Photo Albums

Today I finished working out the kinks in my new photo album workflow.  The result: all of my photo sets since I moved to Corvallis are now available on the site’s Photography section.  I’m keeping the Flickr site for my best photography, but I’ve had all of these images sitting in Lightroom that I suspect friends would love copies of, so now they’re available.

For the curious, I do all of my photo editing in Adobe Lightroom (and occasionally Photoshop).  Using a heavily-modified version of the TTG Shadowbox Gallery Template, I export each album and upload the static HTML and image files to my server.  Nothing terribly exciting there, but now it gets interesting.  I wanted to have an index page that automatically shows all of my galleries, displaying the most recent first.  TTG supplies an XML AutoIndex module that does nearly everything I want, so I integrated that as my index page and hacked the PHP scripts to include better date and description information.  Finally, I wanted to provide an RSS feed of my photo albums, so people won’t need to constantly visit my website if they’re looking for new photos.  A quick modification to the XML AutoIndex script did the trick, so now you can subscribe to an Atom feed of my photo albums!

Everything seems to be working fine for my on Firefox and Safari.  If anyone notices problems with the photo albums or feed, please let me know.