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)
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 .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 ../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 ../cd ~/Downloads/php-5.2.8/ext/gd
phpize
MACOSX_DEPLOYMENT_TARGET=10.5 \
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 \
--with-xpm-dir=/usr/X11R6
make
sudo make installsudo nano /System/Library/LaunchDaemons/org.apache.httpd.plist<array>
<string>/usr/bin/arch</string>
<string>-i386</string>
<string>/usr/sbin/httpd</string>
<string>-D</string>
<string>FOREGROUND</string>
<array>This will ensure that Apache starts in 32 bit mode, which is needed as the gd extension was compiled for i686.
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
Comments
thx for the article! helped a
thx for the article!
helped a lot i'm now able to use the GD library on my macbookpro (osx 10.5.7)!
cheers,
superfly
This has been very helpful.
This has been very helpful. A few comments:
1) The download link in step 2 should point to http://www.php.net/get/php-5.2.8.tar.bz2/from/a/mirror
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.
Post updated
Thanks for the fixes, I updated the post. I'm glad you found it useful!