Feb. 8, 2009, 4:57 p.m.
IT

Drupal on Mac OS X Leopard and Apache/GD

I have been developing a couple of sites now using the Drupal CMS. It works great on Mac OS X, but there is one challenging aspect when trying to get the image manipulation functionality to work, as this needs the GD library but Apache as it is distributed with Mac OS X Leopard does not include that library. Most sites will tell you how to compile the GD library, however you will find for a mysterious reason your GD support will be FALSE. This article explains why and how to fix it. The reason it breaks - and it breaks only on Core 2 Duo MacBook's and Intel Xeon Mac Pro's - is because these operating systems are using the 64-bit version of Apache. So your compiler flags must be adjusted. So the steps are:

  1. Download libjpeg, extract and run:
  2. MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -bindatload" ./configure --enable-shared
  3. then the normal make and make install
  4. Download PHP 5.2.4 source, extract, change directory to ext/gd and run:
  5. MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -bindatload" ./configure --with-zlib-dir=/usr --with-jpeg-dir=/usr/local/lib --with-png-dir=/usr/X11R6 --with-freetype-dir=/usr/X11R6 --with-xpm-dir=/usr/X11R6 --with-gd
  6. then the normal make and make install
  7. Add extension=gd.so to your php.ini file.
  8. Comment out the extension_dir = "./" like in php.ini
  9. Enable the php5_module in apache2's configuration (make sure you use /etc/apache2/http.conf as the other file located at /etc/httpd/httpd.conf is for an older version of Apache.)
  10. Should be all done now.