PHP not loading php_pgsql.dll on Windows PHP not loading php_pgsql.dll on Windows postgresql postgresql

PHP not loading php_pgsql.dll on Windows


Check out the info on the PHP PostgreSQL installation page: http://us.php.net/manual/en/pgsql.installation.php

On a Windows server, configured with Apache, adding the following line to httpd.conf to load libpq.dll can save you a lot of time :

LoadFile "C:/Program Files/PostgreSQL/8.4/bin/libpq.dll"

Note that you will have to change your folder accordingly to the installation path and version of PostgreSQL you have installed. Also note that having Apache and PostgreSQL on the same server for production environments is not recommended.

This fixed my setup instantly.


This happened to me also with PHP 5.4.1

Copying the offending DLL everywhere didn't work, and I don't have PostgreSQL installed in the server, but I also planned to use PHP against different Postgres versions, so the only solution I found that worked was to put in httpd.conf a line like this:

LoadFile "C:/Program Files/PostgreSQL/8.4/bin/libpq.dll"

And referring to the libpq.dll that comes bundled with PHP, like this:

LoadFile "C:/php/libpq.dll"

After that it worked fine to me.


For those willing to make their PHP install only capable to access PostGres servers, without actually installing PostGres, you need to:

  • enable php_pgsql.dll (and php_pdo_pgsql.dll, if using PDO) extension in PHP.INI,
  • make sure libpq.dll, libiconv-2.dll and libintl-8.dll are in the path. These are the php_pgsql.dll dependencies.

These 3 DLLs can be found in the PostGres install. I just copied them into apache\bin, that way I keep everything self contained. Doing that, apache can start the PHP engine just fine, with PostGres support.