在 Windows 上配置 PHP 和 PostgreSQL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6518694/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 00:37:25  来源:igfitidea点击:

Configure PHP and PostgreSQL on Windows

phppostgresql

提问by Ahmad

I'm installing PHP, Apache and PostgreSQL Manually

我正在手动安装 PHP、Apache 和 PostgreSQL

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

PHP 和 Apache 现在已连接,但 PostgreSQL 未连接到 PHP。

i test by using phpinfo();

我使用 phpinfo() 进行测试;

i also configure in php.ini like this :

我也在 php.ini 中这样配置:

extension=php_pgsql.dll
extension=php_pdo_pgsql.dll

But why it's not work.

但为什么它不起作用。

Thanks

谢谢

回答by Igor Hrcek

This tutorialworked for me:

本教程对我有用:

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

PHP 扩展将查找libpq.dll您的 PostgreSQL 安装。简单的解决方法是将包含该文件的路径添加到您的环境路径中。

回答by Erik Verheij

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;

我在 Windows 10 上使用 PHP7 和 Apache 2.4 遇到了同样的问题。对我来说,解决方案是将以下行添加到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.

这也意味着如果您只想连接不在您的机器上运行的 PostgreSQL 数据库,则不需要安装 PostgreSQL。

回答by aorlando

1) Installing PostgreSQL for Windows

1) 安装 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)

2)将PostgreSQL安装的bin文件夹添加到环境变量“PATH”中:C:\Program Files\PostgreSQL\9.2\bin;(例如)

回答by Mohammad Yusuf

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

假设你已经安装了 PostgreSQL 并且你的 WAMP 安装在 c:\wamp,你需要将 c:\wamp\bin\php\php5.3.9\libpq.dll 复制到 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

确保您还有以下文件 C:\wamp\bin\php\php5.3.9\ext\php_pdo_pgsql.dll 和 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)

另外,请确保您已通过 WAMP 菜单启用上述 2 个文件作为扩展名(单击任务栏上的 WAMP 图标、PHP、PHPExtensions,找到上述 2 个文件并“检查”它们)

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

请注意,php5.3.9 和 Apache2.2.11 是指我的特定 PHP 和 Apache 版本。调整它们以适合您的安装。

That's it!

就是这样!

回答by rtfmpliz

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

就我而言,有 2 个 php.ini,我不得不在 php.ini 中取消注释扩展 pdo_pgsql

  1. in php folder
  2. in apache folder
  1. 在php文件夹中
  2. 在 apache 文件夹中

both inside in wamp folder

都在 wamp 文件夹中