Sorry for taking so long in answering back, I've been a bit busy this week.
Anyway, the way I build php/postgresql/apache:
cd /usr/local/src
tar -xvzf /root/apache_1.3.19.tar.gz
tar -xvzf /root/php-4.0.5.tar.gz
tar -xvzf /root/postgresql-7.1.tar.gz
cd apache_1.3.19
./configure --prefix=/www \
--enable-module=most \
--enable-shared=max
make
make install
cd ../postgresql-7.1
./configure --enable-odbc \
--with-max-backends=1024 \
--with-tcl
make
make install
cd ../php-4.0.5
./configure --with-apxs=/www/bin/apxs \
--with-pgsql
make
make install
That should all work. Note that I install postgresql to the default /usr/local/pgsql directory here. If you used a --prefix=/db switch for postgres, then you need to do a --with-pgsql=/db for php to tell it where to find the pgsql installed directory. Note that unlike some other apps, php wants the directory postgresql was installed to, not from.