So this is how I rebuilt it to have soap enabled. I also wanted to add Pspell support, so that's here too.
Mac Ports to the rescue
At first I tried Mac Ports, and it didn't work, so I messed around with configuration files quite a lot, downloading individual packages and components, and it all got too hard.
Then I realised that I was simply using the wrong variants in MacPorts. So. here it is:
port install php5 +apache2 +macosx +mysql5 +pear +pspellViola! it's built.
What about MySQL?
MacPorts has just downloaded and compiled and built and installed the latest mysql5 into /opt/local . However, in my case, I already had MySQL installed, from the MacOSX installer available directly from the MYSQL website. So, I decided to do a very quick solution, like this:
At a shell (root user required):
# make a link for the mysql socket back to the one already running
mkdir -p /opt/local/var/run/mysql5
ln -s /tmp/mysql.sock /opt/local/var/run/mysql5/mysqld.sock
So, in reality, our new version of php is only using the new MySQL client libraries, which are still capable of working with quite a variety of versions of MySQL servers. In my case, here, the client is 5.0.51 and the server is 5.0.45.
Subbing out PHP - old for new
I don't really like deleting stuff until I know it's all working, so I substituted old for new like this:
At a shell (root user required):
cd /usr/bin
# backup old php & phpize
mv php php-leopard
mv phpize phpize-leopard
# replace them with links to the new MacPort ones in /opt/local
ln -s /opt/local/bin/php php
ln -s /opt/local/bin/phpize phpize
# do similar for libraries
cd /usr/lib
mv php php-leopard
ln -s /opt/local/lib/php php
# and similar again for includes:
cd /usr/include
mv php php-leopard
ln -s /opt/local/include/php php
# and sub out the apache php module
cd /usr/libexec/apache2
mv libphp5.so linphp5.so.leopard
ln -s /opt/local/apache2/modules/libphp5.so /usr/libexec/apache2/libphp5.so
Restarting Apache
Apache needs to be restarted, as the old PHP module is still in memory:
At a shell (root user required):
apachectl restart
Conclusion
I now have the latest PHP installed, and with a few extra features to boot.
Thank you MacPorts.