Compiling PHP Zip module for OSX
Wednesday, 10 Dec 2008After 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.
-Extract the package in a folder of your choice, eg: ~/src/zip-1.8.10
Optionally test the result:
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.10Depending 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 testYour 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.soHope it was as easy for you as it was for me!
Posted in: php osx: leopard



Comments (2)
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...