By default, the vanilla PHP that ships with MacOS X doesn't support PostgreSQL.
How hard could this be? Compile PHP and change the modules files for Apache, right? So, I tried this. Which, BTW, wasn't a hassle-free thing to do. Many many thanks to "fatalerror" at WordPress for this fantastic guide which got the ball rolling for me.
After the install, I noticed that Apache simply won't load the PHP module, because the dynamic library that the PHP-compile built is for i386, and Apache was compiled by Apple for x86_64.
Many hours later of trying to get the PHP-compile to produce x86_64 targets, I gave up, and decided to go whole-hog; i.e., not just replacing PHP, but by compiling the world for i386--at least, enough of the world for Apache 2.2.11, PostgreSQL 8.3.7, and PHP 5.2.9 (including GD and GNU Readline).
Since I'm working with other Mac developers, all whom will need this solution, I decided to make a tarball...Which meant making the installation as hassle-free as possible. Since this stuff has to be done as root, (to install to /usr/local, etc), I wanted to make sure I wasn't doing anything that couldn't be reviewed by someone downloading my bundle. So, I decided to write a pretty easy-to-read Makefile.
Then I got started...
Turns out that although most packages compile with a simple ./configure, some don't. And, in those cases, we have to patch some Makefiles here and there; so that they'll, for example, install directories (shame on jpeglib for shoddy install work!!). Of course, that meant patching things in a way that configure will understand.
But, after many more hours of work, I got the whole apache/php/postgres world to compile, in an almost-fully-automated fashion on MacOS X. A simple phpinfo test was successful, and revealed that all the pieces were joined the way I wanted.
:))) -- w00t
The rest of the patches are for allowing the new Apache to be started and stopped through System Preferences (!), and configuring the new Apache once the new Apache is installed. This includes turning on support for user-directories (via ~/Sites, per Apple's way), using Apple's users for running httpd, (why redo *ALL* those perms?), and using custom log files, so that in case you ever want to revert back to the vanilla apache, log files aren't lost.
There is a tiny of bit of interaction at the end of the install, for the PEAR install. Just press [Enter] to accept the defaults (a couple of times, IIRC). That's it. Read the README file in the tarball; it will tell you how to test it. Test it--esp. before you comment, if you're going to do that.
The feature I like best is the one that allows this new Apache to be started and stopped through System Preferences. It just involved editing one line in /System/Library/LaunchDaemons/org.apache.httpd.plist to point to the new binary. If you ever need to go back to the vanilla Apache, make the obvious change. If this fact daunts you, don't install this package--you don't know what you're doing.
* * *
If I haven't scared you away, here a tiny tarball with my solution: epic-bundle.tar.gz.
(p.s. I don't take any responsibility for mucking up your machine--all this stuff runs as root (via sudo)--read the Makefile, understand what it does, and figure how to undo it before you use it!!)