'Configure PHP and PostgreSQL on Windows

I'm installing PHP, Apache and PostgreSQL Manually

PHP and Apache now is connected, but PostgreSQL is not connected to PHP.

i test by using phpinfo();

i also configure in php.ini like this :

extension=php_pgsql.dll
extension=php_pdo_pgsql.dll

But why it's not work.

Thanks



Solution 1:[1]

This tutorial worked for me:

The PHP extension will look for libpq.dll which is found of your PostgreSQL installation. The simple fix is to add the path than contains that file to your environment PATH.

Solution 2:[2]

I had the same issue with PHP7 and Apache 2.4 on Windows 10. For me the solution was to add the following line to httpd.conf;

LoadFile "C:/php7/libpq.dll"

This also means that it's not required to have PostgreSQL installed if you just want to connect a PostgreSQL database that's not running on your machine.

Solution 3:[3]

1) Installing PostgreSQL for Windows

2) add to your enviroment variable "PATH" the bin folder of PostgreSQL installation: C:\Program Files\PostgreSQL\9.2\bin; (for example)

Solution 4:[4]

Assuming you have installed PostgreSQL and your WAMP installation is on c:\wamp, you will need to copy c:\wamp\bin\php\php5.3.9\libpq.dll to c:\wamp\bin\apache\Apache2.2.11\bin

Make sure you also have the following files C:\wamp\bin\php\php5.3.9\ext\php_pdo_pgsql.dll and C:\wamp\bin\php\php5.3.9\ext\php_pgsql.dll

Also, make sure you have enabled the above 2 files as extensions, either via the WAMP menu (click on WAMP icon on taskbar, PHP, PHPExtensions, find the above 2 and 'check' them)

Please note that php5.3.9 and Apache2.2.11 refer to my specific PHP and Apache versions. Adjust those to suit your installation.

That's it!

Solution 5:[5]

in my case there are 2 php.ini, I had to uncomment extension pdo_pgsql in both php.ini

  1. in php folder
  2. in apache folder

both inside in wamp folder

Solution 6:[6]

If you are using PHP in IIS, using PHP Manager, enable this extension:

php_pgsql.dll

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Cees Timmerman
Solution 2 Erik Verheij
Solution 3 aorlando
Solution 4 Mohammad Yusuf
Solution 5 rtfmpliz
Solution 6 tno2007