Author Topic: Adding GD to PHP5 on Leopard  (Read 561 times)

Offline scotbuff

  • Sys Admin
  • UNIX User
  • *****
  • Posts: 174
  • Karma: +2/-0
    • View Profile
    • Scott.Buffington.me
Adding GD to PHP5 on Leopard
« on: December 19, 2007, 02:51:12 pm »
If you look at previous posts you will see that with Tiger I always compiled PHP and prereqs and also Apache.  With Leopard I decided I would try to use the preinstalled versions, especially since Leopard had PHP5.  One problem, PHP5 did not have GD.  You can add GD by following these steps.  I have seen this documented exactly elsewhere, and I used the instructions elsewhere and documented my steps here for my purposes.  If you find them helpful, great!  You may have to use sudo.  Please for all that is holy do not enable root, it just is not necessary.  Sudo is there, us it.

I keep a source directory in my home directory named src.  If you want to put the source files somewhere else, be sure to change my instructions to match your directory.
Download jpeg library
cd ~/src
wget http://www.ijg.org/files/jpegsrc.v6b.tar.gz  (Note, if you do not have wget, replace the command with curl -O)
tar xzpf jpegsrc.v6b.tar.gz

Install libjpeg
cd jpeg-6b
cp /usr/share/libtool/config.sub .
cp /usr/share/libtool/config.guess .
For 32-bit use:
./configure --enable-shared
For 64-bit use:
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 -bind_at_load" ./
configure --enable-shared
make
sudo mkdir -p /usr/local/include
sudo mkdir -p /usr/local/bin
sudo mkdir -p /usr/local/lib
sudo mkdir -p /usr/local/man/man1
sudo make install

Now We Get and Install the GD Library
cd ..
Everyone recommends for maximum compatibility you get PHP from Darwin Sources.
wget http://www.opensource.apple.com/darwinsource/10.5/apache_mod_php-43/php-5.2.4.tar.bz2
tar xjf php-5.2.4.tar.bz2
cd php-5.2.4/ext/gd
phpize
For 32-bit use:
./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
For 64-bit use:
MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS="-arch ppc -archppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch ppc-arch ppc64 -arch i386 -archx86_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 -bind_at_load" ./
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
make
sudo make install

I then inserted: extension=gd.so into /etc/php.ini where the Dynamic Extensions section is.  Really, you can most likely append this in the /etc/php.ini file and it will work.  You also must comment out the following line within /etc/php.ini, or your installation will not work.
extension_dir = "./"
Just place a semi-colon as the first character of the line, like so:
;extension_dir = "./"

Cycle Apache
sudo apachectl graceful

Enjoy!