Here are bits of info I have gathered regarding using and updating PHP on a Macintosh. Also see PHP Mac and the main PHP site for more information.

Enabling PHP on Panther

PHP comes built-in with OSX 10.3. You just need to enable it as follows:

Edit /etc/httpd/httpd.conf and uncomment two lines. If you have bbedit installed (my favorite text editor), you can just enter this from the terminal: sudo bbedit /etc/httpd/httpd.conf.

LoadModule php4_module        libexec/httpd/libphp4.so
AddModule mod_php4.c

Save your changes and restart apache as follows: sudo apachectl restart.

Building and Installing GD Lib with PNG, WBMP, and JPEG support

I got these instructions from this site. But I had a few problems, so I have included the instructions here, intersperced with my comments.

Downloading the source

Create a directory for working in. In my case that directory is ~/Projects/gdbuild. Everything that follows is done in the terminal.

cd ~/Projects/gdbuild
curl -O ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz
curl -O http://public.planetmirror.com/pub/sourceforge/libpng/libpng-1.2.5.tar.gz
curl -O http://www.boutell.com/gd/http/gd-1.8.4.tar.gz

Untar the source

gnutar xzf jpegsrc.v6b.tar.gz
gnutar xzf libpng-1.2.5.tar.gz
gnutar xzf gd-1.8.4.tar.gz

You can now lose the compressed files: rm *.gz.

Build and install JPEG support

cd jpeg-6b
./configure
make 
sudo make install
sudo make install-lib
sudo ranlib /usr/local/lib/libjpeg.a
cd ..

During the sudo make install part I got some errors about missing directories. I had to create the following before continuing:

sudo mkdir /usr/local/man
sudo mkdir /usr/local/man/man1
sudo mkdir /usr/local/include
sudo mkdir /usr/local/lib

Build and install PNG support

cd libpng-1.2.5
cp scripts/makefile.macosx ./Makefile
bbedit Makefile

In the editor window for Makefile, make these changes:

  1. Change ZLIBLIB=../lib to ZLIBLIB=/usr/lib
  2. Change ZLIBINC=../lib to ZLIBINC=/usr/include
  3. Change the line that reads:
    LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -current_version $(PNGVER)
    to this:
    LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz
  4. Save and exit
make
sudo make install
sudo ranlib /usr/local/lib/libpng.a
cd .. 

Build and install GD Lib

cd gd-1.8.4
bbedit Makefile

In the editor window delete the following from the Makefile:

-I/usr/include/X11
-I/usr/include/freetype2
-L/usr/lib/X11

Save your changes and exit.

% make 
% make install
% sudo ranlib /usr/local/lib/libgd.a
cd ..

Ignore any warnings or errors that occur during the last step.

Adding GD support to PHP

To do this, just follow the next section on installing the latest version of PHP. If you have already done the following, just skip down to the part that starts with ./configure ...

Installing the latest version of PHP

The most current version as of the time of this writing is 4.3.5 RC3. You can always check to see what the most current version is by looking here. Anyway, download this: http://downloads.php.net/ilia/php-4.3.5RC3.tar.bz2. Uncompress/untar it and put the resulting folder "php-4.3.5RC3" wherever you like. On my machine it is located here: ~/Projects/php-4.3.5RC3. Now from the terminal:

cd ~/Projects/php-4.3.5RC3
./configure --with-xml --with-zlib --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-apxs=/usr/sbin/apxs
make
sudo make install
sudo apachectl restart

That's it!