If you want to do some graphics work within PHP you will need the GD library. It will take several steps of preparation before you can add this to PHP. First you need to download the source code from the Freshmeat libjpeg project.
First unpack the source code and then go into the newly created folder and execute the following commands:
cp /usr/share/libtool/config/config.sub . cp /usr/share/libtool/config/config.guess .
Which will copy these files to the current directory. They are required for the configuration phase of this installation.
export MACOSX_DEPLOYMENT_TARGET=10.7 ./configure --enable-shared
Next follow with the commands:
make sudo make install
To compile and install the library.
Next step is to recompile the php installation as described on this page: Compiling PHP.
The only change you need to make is to add:
--with-gd \ --with-jpeg-dir=/usr/local/lib \ --with-png-dir=/usr/X11R6 \ --with-freetype-dir=/usr/X11R6 \ --with-xpm-dir=/usr/X11R6 \
To the configure statement and it will include this library for you.
./configure --prefix=/usr/local/php5 \ --mandir=/usr/share/man \ --infodir=/usr/share/info \ --sysconfdir=/etc \ --with-config-file-path=/etc \ --with-zlib \ --with-zlib-dir=/usr \ --with-openssl \ --without-iconv \ --enable-exif \ --enable-ftp \ --enable-mbstring \ --enable-mbregex \ --enable-sockets \ --with-mysql=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-mysqli=mysqlnd \ --with-gd \ --with-jpeg-dir=/usr/local/lib \ --with-png-dir=/usr/X11R6 \ --with-freetype-dir=/usr/X11R6 \ --with-xpm-dir=/usr/X11R6 \ --with-apxs2=/usr/local/apache2/bin/apxs
By the way if you run into the error:
checking for jpeg_read_header in -ljpeg... yes configure: error: libpng.(a|so) not found.
You didn’t install X11 when you installed OS X. You can still install it using the “optional installs” and select X11 from Applications and install it on the default location.