php 在 WAMP 上集成 postgreSQL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/14621181/
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
Integration of postgreSQL on WAMP
提问by Ammar Hayder Khan
I have just installed the postgreSQL on windows 7. I am trying to integrate postgreSQL with WAMP server. For this i have done the following changes in httpd.conf and php.ini file
我刚刚在 Windows 7 上安装了 postgreSQL。我正在尝试将 postgreSQL 与 WAMP 服务器集成。为此,我在 httpd.conf 和 php.ini 文件中做了以下更改
1 LoadModule c:/pathto libpq.dllin httpd.confand then
1 LoadModulec:/path到libpq.dllinhttpd.conf然后
2 extension=php_mod_pgsql.dll, extension=php_pgsql.dll-- enable(reemove ;) in php.ini
2 extension=php_mod_pgsql.dll, extension=php_pgsql.dll-- enable(reemove ;) inphp.ini
If I do the above changes the localhost does not work.
如果我进行上述更改,本地主机将不起作用。
If I do the second changes the localhost work but does not load the libpq.dll.
如果我做第二次更改 localhost 工作但不加载libpq.dll.
I checked the pgsql by php script by this
我通过这个 php 脚本检查了 pgsql
<?php
 echo extension_loaded('pgsql') ? 'yes':'no';
 ?>
The script shows "yes", but apache is not loading the libpq.dll.
Now what i should do for load the postgreSQL into the Apache2.2* (wamp)
脚本显示“是”,但 apache 没有加载libpq.dll. 现在我应该怎么做才能将 postgreSQL 加载到 Apache2.2* (wamp) 中
回答by rails_id
- After installation of PostgreSQL, you need to copy 
libpq.dllfromwamp\bin\php\phpX.X.Xtowamp\bin\apache\Apache2.2*\bin. And restart the Wampserver. - Download phpPgAdminhere.
 - Extract phpPgAdmin-5.1.zipin 
C:\wamp\appsSo the path will be,C:\wamp\apps\phpPgAdmin-5.1. Create a file called
phppgadmin.confinC:\wamp\alias. And copy paste the following :Alias /phppgadmin "C:/wamp/apps/phpPgAdmin-5.1/" <Directory "C:/wamp/apps/phpPgAdmin-5.1/"> Options Indexes FollowSymLinks MultiViews AllowOverride all Order Deny,Allow Allow from all </Directory>Left Click on the Wampserver Tray icon. Navigate to PHP > PHP extension. Then enable this
a. php_pgsql b. php_pdo_pgsql extension.Open
C:\wamp\apps\phpPgAdmin-5.1\conf\config.inc.php,a. find
$conf['servers'][0]['host'] = '';change to$conf['servers'][0]['host'] = 'localhost';
b. find$conf['extra_login_security'] = true;changetruetofalseRestart All service
Go to
http://localhost/phppgadmin/and try to login.Default Login credentials are
- Username = "postgres"
 - Password = "root"
 
- 安装后的PostgreSQL,你需要复制
libpq.dll的wamp\bin\php\phpX.X.X到wamp\bin\apache\Apache2.2*\bin。并重新启动 Wampserver。 - 在此处下载phpPgAdmin。
 - 将phpPgAdmin-5.1.zip解压到
C:\wamp\apps所以路径为,C:\wamp\apps\phpPgAdmin-5.1. 创建一个名为文件
phppgadmin.conf在C:\wamp\alias。并复制粘贴以下内容:Alias /phppgadmin "C:/wamp/apps/phpPgAdmin-5.1/" <Directory "C:/wamp/apps/phpPgAdmin-5.1/"> Options Indexes FollowSymLinks MultiViews AllowOverride all Order Deny,Allow Allow from all </Directory>左键单击 Wampserver 托盘图标。导航到 PHP > PHP 扩展。然后启用这个
a. php_pgsql b. php_pdo_pgsql extension.打开
C:\wamp\apps\phpPgAdmin-5.1\conf\config.inc.php,一种。找到
$conf['servers'][0]['host'] = '';对$conf['servers'][0]['host'] = 'localhost';
b 的更改。寻找$conf['extra_login_security'] = true;变化true到false重启所有服务
转到
http://localhost/phppgadmin/并尝试登录。默认登录凭据是
- 用户名 = "postgres"
 - 密码 = "root"
 
references :
参考 :
回答by Jessica Gramp
Thank you. These instructions worked once I also added 'Require local' to the phppgadmin.conf file:
谢谢你。一旦我还在 phppgadmin.conf 文件中添加了“需要本地”,这些说明就起作用了:
Alias /phppgadmin "C:/wamp/apps/phpPgAdmin-5.1/" 
<Directory "C:/wamp/apps/phpPgAdmin-5.1/">
    Require local
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
        Order Deny,Allow
  Allow from all
</Directory>
回答by Sammee Mushtaq Bazaz
it worked thank you
成功了,谢谢
Alias /phppgadmin "C:/wamp/apps/phpPgAdmin-5.1/" 
<Directory "C:/wamp/apps/phpPgAdmin-5.1/">
    Require local
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
        Order Deny,Allow
  Allow from all
</Directory>
回答by Pankaj
After Enabling Postgresql extension from WAMP icon i was able to get postgresql admin page but
bin/cake bake allcommand was failing with error 'php extn missing'. (referred @rails_id's post below to complete postgresql integration with WAMP)checked in cmd prompt with
php -m, no "postgresql" module was present.Went to php installation directory, in my case it was "C:\wamp64\bin\php\php7.2.10" and enabled (removed the ;) following pg module in php.ini file:
extension=pdo_pgsql extension=pgsql
restarted the wamp services.
bin/cake bake allis working fine from command prompt.
从 WAMP 图标启用 Postgresql 扩展后,我能够获得 postgresql 管理页面,但
bin/cake bake all命令失败并出现错误“php extn missing”。(在下面引用@rails_id 的帖子以完成 postgresql 与 WAMP 的集成)在 cmd 提示符下检查
php -m,没有“ postgresql”模块存在。转到php安装目录,在我的情况下它是“C:\wamp64\bin\php\php7.2.10”并在php.ini文件中启用(删除了;)以下pg模块:
扩展=pdo_pgsql 扩展=pgsql
重新启动了 wamp 服务。
bin/cake bake all在命令提示符下工作正常。
回答by rilut
Don't forget that WAMP has two php.inifiles. One in Apache directory, one in php directory (bin\php\php5.X.X). Wampserver Tray manages the one in Apache directory.
不要忘记 WAMP 有两个php.ini文件。一份在 Apache 目录中,一份在 php 目录 ( bin\php\php5.X.X) 中。Wampserver Tray 管理 Apache 目录中的一个。
To be able to run php cli tools (e.g php artisan), you need to uncomment the php_pgsqland php_pdo_pgsqlin the php.iniin php directory.
为了能够运行PHP的CLI工具(如php artisan),则需要取消注释php_pgsql,并php_pdo_pgsql在php.ini在PHP目录。
回答by Chris Travers
Probably the best place to start is with the msdn docs.  It looks like the simplest fix is to set the %PATH%environment variable system-wide to include the path to libpq.dll.
最好的起点可能是msdn 文档。看起来最简单的修复方法是在%PATH%系统范围内设置环境变量以包含 libpq.dll 的路径。
Note that %PATHis searched last, so if a libpq is ever put into the system directory or the Apache directory it will be caught first.
请注意,%PATH最后搜索的是 libpq,因此如果将 libpq 放入系统目录或 Apache 目录,它将首先被捕获。

