Hi,
try the following:
1) Download the PHP sources that match the installed PHP version.
2) Make sure that PostgreSQL is installed and that the PostgreSQL headers and libraries exist.
3) Now execute the configure script with hardly any options since you don't want to install the complete stuff (you only need the shared pgsql extension). Make sure to use the following option
--with-pgsql=shared
and maybe with --without-mysql
4) execute make
5) locate the shared library pgsql.so and copy it to the PHP extensions folder (as set in the php.ini file)
6) add the line extension=pgsql.so to php.ini
7) restart the web server
I never did that with the PostgreSQL extension but with several other extensions and it worked.
Do not execute 'make install' since this might break your existing installation.
EDIT: If the configure script can't find PostgreSQL then try
--with-pgsql=shared,/path/to/postgresql
Thomas