Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using postgresql with php under windows/xampp

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.

like image 568
maja Avatar asked Jun 22 '13 14:06

maja


1 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:

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.

like image 50
maja Avatar answered Sep 20 '22 22:09

maja