PHP not loading php_pgsql.dll on Windows

PHP 5.2.8 is refusing to load php_pgsql.dll, with the following error:

Warning: PHP Startup: Unable to load dynamic library 'D:\PHP\ext\php_pgsql.dll' - The specified module could not be found.

in Unknown on line 0

The .dll exists in PHP/ext/.

Has anyone else had this problem with PHP on Windows before?


Solution 1:

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.

Solution 2:

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.