Compiling PHP on Snow Leopard

If you’ve been having trouble compiling your own PHP installations on Mac OS X 10.6, here’s the secret to making it not suck! After running the configure script, edit the generated Makefile and make these fixes:

  • Find the EXTRA_LIBS definition and add -lresolv to the end
  • Find the EXE_EXT definition and remove .dSYM

Standard make and make install should work from here…

For reference, here’s the whole configure line I currently use; MySQL is installed from the downloadable installer; other deps from MacPorts:

‘./configure’ ‘–prefix=/opt/php52’ ‘–with-mysql=/usr/local/mysql’ ‘–with-zlib’ ‘–with-bz2’ ‘–enable-mbstring’ ‘–enable-exif’ ‘–enable-fastcgi’ ‘–with-xmlrpc’ ‘–with-xsl’ ‘–with-readline=/opt/local’ –without-iconv –with-gd –with-png-dir=/opt/local –with-jpeg-dir=/opt/local –with-curl –with-gettext=/opt/local –with-mysqli=/usr/local/mysql/bin/mysql_config –with-tidy=/opt/local –enable-pcntl –with-openssl