Compiling PHP Zip module for OSX

Wednesday, 10 Dec 2008
After spending way too much time figuring out how to add modules to existing PHP installations on OSX, I realized this should be worth sharing. The procedure below works on Leopard, but should work on Tiger just as well (just not tested). Compiling the zip module yourself is very easy, but requires you to have the Apple Developer Tools (XCODE) installed.

Download & Extract

-Download the ZIP package from PECL
-Extract the package in a folder of your choice, eg: ~/src/zip-1.8.10

Compile your own zip.so

Open up a terminal window, and navigate to your src folder.
cd ~/src/zip-1.8.10
Depending on your temporary location, you may need to run some of the following commands as root (prefix sudo to these commands to achieve this). Now do the actual compilation of the zip module:
./configure
make

Optionally test the result:
make test
Your zip.so module will be waiting for you in modules/. Move/copy it to your php extensions (I recommend you just use Finder if you're able to navigate both source and target), and enable it in your PHP configuration file php.ini:
extension=zip.so
Hope it was as easy for you as it was for me!
Posted in: php osx: leopard
Add comment

Comments (2)

08-09-2009, 22:43
Steve
Thanks for the article... although I couldn't quite get the instructions to work as above, they pointed me in the right direction, which got things resolved...!
06-10-2009, 18:57
Steve
Three weeks later, different machine, and I had to do this again, which meant I had to scratch my head and work out the missing bits again to get this to work on Snow Leopard, so here they are.

With the current version of the zip package which you download from pecl above, before you can run ./configure (because there isn't one when initially unzipped) you'll need to do
sudo pecl build
from terminal. This will most likely result in an error telling you that pcre.h is missing from /usr/include/php/ext/pcre

You can resolve this by downloading the source for the latest version of pcre from ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/

Once you have that you need to untar the file and run the following command in the resulting folder
./configure
Then copy the resulting pcre.h to the folder above.

Once all that's done, you can follow the instructions above...