7

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

extension=php_pdo_mysql.dll
extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll

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\9.2\bin
C:\xampp\php\ext

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.

3
  • @Denis How can I find out, if it's a permission-problem? Commented Jun 22, 2013 at 14:56
  • "'C:\xampp\php\ext\php_pdo_pgsql.dll' - Das angegebene Modul wurde nicht gefunden." -- if the file actually exists, but is reported as not found regardless, it probably means it isn't readable. Look at the file's permissions in Windows Explorer, and compare them to the permissions of similar dll files. Commented Jun 22, 2013 at 15:12
  • It has the same permissions, as the other files in this directory Commented Jun 22, 2013 at 15:20

2 Answers 2

17

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:

extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
extension=php_pgsql.dll

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

After reading this:

http://postgresql.1045698.n5.nabble.com/pgAgent-installation-fails-LIBPQ-DLL-is-missing-PostgreSQL-9-0-2-x64-2008-Windows-Server-x64-td3351434.html

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.

Sign up to request clarification or add additional context in comments.

4 Comments

I installed it on a new PC, and it also works on Windows 8.1 with Postgres 9.3. Changing the Path-Variable isn't neccessary.
were you able to get it working with postgre 64-bit ?
replaced the DLL from there - please explain, what do you mean ? You replaced a 9.x dll with the 8.4 dll you downloaded ?
Yes, I replaced the 9.x-dll with an 8.4-dll. And I haven't tried it with a 64-bit installation yet.
6

Another solution for this is copying

c:/xampp/php/libpq.dll

to

c:/xampp/apache/bin/

Source

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.