Adding support for the GD graphic library on OS X 10.5 Leopard

I play around with a number of Drupal locally and today I finally caved in and decided to add GD support to OS X's webserver. Although I've heard great things about the Entropy PHP packages, I did not want to replace OS X's integrated php installation so my remaining option was to grab a copy of PHP 5.2.8 (the version bundled with Leopard) and compile the module myself. I know there must be quite a few other people who are looking do to the same thing, so I here's a step-by-step guide on how I did it:

(Please note that I assume you have Xcode installed, and that all downloads are saved in the "Downloads" folder in your home. If this is not the case, please move the downloads there first before executing any of the listed commands)

  1. Visit the libpng and libjpeg homepages and download the latest release available for both. As of writing, the most recent releases are libjpeg 7 and libpng 1.2.37 - the commands below will need to be adjusted slightly if you are compiling a more recent version.
  2. Download PHP 5.2.8, available here
  3. Extract PHP and prepare to compile libpng and libjpeg statically:
    cd ~/Downloads
    tar xfj php-5.2.8.tar.bz2
    cd php-5.2.8/ext/gd
    mv ~/Downloads/libpng-1.2.37.tar.gz ~/Downloads/jpegsrc.v7.tar.gz .
  4. Compile libpng without shared libraries:
    tar xfz libpng-1.2.37.tar.gz && cd libpng-1.2.37
    ./configure --disable-shared --enable-static
    make && make install DESTDIR=`pwd`/localinstall
    cd ../
  5. Compile libjpeg without shared libraries:
    tar xfz jpegsrc.v7.tar.gz && cd jpeg-7
    cp /usr/share/libtool/config.* .
    ./configure --disable-shared --enable-static
    make && make install DESTDIR=`pwd`/localinstall
    cd ../
  6. Compile the GD extension and point to our newly compiled libpng and libjpeg static libraries:
    cd ~/Downloads/php-5.2.8/ext/gd
    CFLAGS="-O3 -fno-common -arch i686" \
    LDFLAGS="-O3 -arch i686" \
    CXXFLAGS="-O3 -fno-common -arch i686" \
    ./configure --with-zlib-dir=/usr \
    --with-png-dir=`pwd`/libpng-1.2.37/localinstall/usr/local \
    --with-jpeg-dir=`pwd`/jpeg-7/localinstall/usr/local \
    --with-freetype-dir=/usr/X11R6 \
    sudo make install
  7. Copy /private/etc/php.ini.default to /private/etc/php.ini
    • Change the default 'extension_dir' (./) to /usr/lib/php/extensions/no-debug-non-zts-20060613/
    • Add a bit below extension_dir to enable the gd extension
  8. sudo nano /System/Library/LaunchDaemons/org.apache.httpd.plist
    Change the part between <array> and </array> so that it looks like this:

    This will ensure that Apache starts in 32 bit mode, which is needed as the gd extension was compiled for i686.
  9. That's all! After a reboot (or toggle Web sharing in the System Preferences), everything should be working. phpinfo() should now confirm that GD library is indeed loaded. If it isn't or if apache refuses to start, try opening Console to check /var/log/apache2/error_log for some useful pointers as to what's wrong.

    Helpful source I used for writing this tutorial: HOWTO: Install Habari on Mac OS X Leopard, From Scratch



This has been very helpful. A few comments:

1) The download link in step 2 should point to

2) There's a couple of places where the version numbers don't match up. You might want to highlight the version numbers with a coloured background to make it easy to see what needs to be modified.

3) The libpng library now only downloads as a .gz file so the tar options are slightly different

4) The --with-jpeg-dir and --with-png-dir directories in step 6 need to be swapped around.

5) Apache can be stopped and restarted from the 'Sharing' item in 'System Preferences' rather than rebooting the system.

Anyway, thanks to your great instructions Drupal doesn't complain in its status report any more and phpinfo() shows lots of added goodies. Now the real work begins...

Thanks again.

Thanks for the fixes, I updated the post. I'm glad you found it useful!

thx for the article!
helped a lot i'm now able to use the GD library on my macbookpro (osx 10.5.7)!

You want us to leave the <array> tag unclosed or was this a typo?

<array> <-------- *unclosed array tag*


Thanks, that was a typo - I meant to close the tag. I've corrected the post :)

Is this tutorial for a regular Mac running Leopard or only a Mac OS X's webserver or both?


It should work on either, I wrote it for myself using OS X 10.5 (retail). I have not tested this on Mac OS X server, but I don't see why it wouldn't work if you wanted to give it a try!

Phew, it all works. It all sincerely works. I wasn't sure it would but getting the program to start in the 32 bit mode was a difficult task so thanks a lot with it. Now I'll go to and get them to complete my research paper.

I got these amazing banners printed through a brochure printing service and the sturdy, strong banners were really eye catching with fast delivery.

waoww didn't knew that it was possible to add support for the GD graphic library on OS X 10.5 Leopard. It can know really help me write a bestessay. Well thank you for sharing the instructions.

This is a great article, Thanks for giving me this information. Keep posting.
venus factor system

I have recently started a blog, the info you provide on this site has helped me greatly. Thanks for all of your time & work.
vert shock book

I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. In fact your creative writing abilities has inspired me to start my own BlogEngine blog now. Really the blogging is spreading its wings rapidly. Your write up is a fine example of it. Law firm SEO

Produce additional content for this theme you do have a fantastic notion for you to promote writters.

instagram likes Hi there, I discovered your blog per Google bit searching for such kinda educational advise moreover your inform beholds very remarkable for me. instagram followers

I just now identified applying indicate the item all over again. Advocate whatsoever I need to to make sure anticipation as a result of honest you will keep on being for the purpose of featuring that excellent organize. Bail Bonds in Atlanta

Great article .please share more. hiking

The step by step guide was definitely helpful as I was struggling with issues regarding this type of server integration. You have provided all the compiling codes along with the links for the downloads which has enabled to successfully run it on my server. Thanks lot for this post. Macallan 12

Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. have a peek at this web-site

So wwe had these generator and all are these because this sims freeplay hack online can give you simoleons.

You have a good point here!I totally agree with what you have said!!Thanks for sharing your views...hope more people will read this article!!! Hero Instinct Phrases