Home » Php » Using postgresql with php under windows/xampp

Using postgresql with php under windows/xampp

Posted by: admin July 12, 2020 Leave a comment


I’m trying to use postgres with PHP, but Apache can’t load the extension.

I’m using:

Windows 7 (64bit) with xampp, and I have php version 5.4.7
I already set up postgres, and other applications can access the databases.

When I uncomment the following lines in my php.ini


I get some errors in the php-error-log:

[22-Jun-2013 13:15:22 UTC] PHP Warning: PHP Startup: Unable to load dynamic library ‘C:\xampp\php\ext\php_pdo_pgsql.dll’ – Das angegebene Modul wurde nicht gefunden.
in Unknown on line 0

But the path is correct, and the files are there.

After some research, I added this line to my http.conf:

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

But whereever I put this line, the apache-service isn’t able to start anymore. So I removed the line.

I also tried to add these 2 paths to my PATH-Variable:

C:\Program Files\PostgreSQL.2\bin

Now the error changed to

in Unknown on line 0

Everything is running on the same, local machine. And using Linux / seperate servers is not an alternative.

My phpinfo() doesn’t show any postgres-related things.

I hope someone knows how to solve the problem, Google didn’t help me at all.

How to&Answers:

Ok, somehow I finally solved the problem:

I reinstalled xampp and postgres but used postgres 32bit-version (The 64bit-version should also work, but i wanted to ensure)

Then I enabled the extensions in php.ini again:


I got the error that the file hasn’t been found again (php_error_log).

After reading this:


I downloaded libpq.dll from postgres 8.4 and copied it both in apache/bin and postgres/lib (replaced the dll from there).

In my Path-Variable there’s still C:\xampp\php\ext\, but it should work without that part too.

I worked on this problem for 3 days and I hope it will help others to get it up and running faster.


Another solution for this is copying