在 windows/xampp 下使用 postgresql 和 php
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17251859/
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
Using postgresql with php under windows/xampp
提问by maja
I'm trying to use postgres
with PHP, but Apache can't load the extension.
我正在尝试使用postgres
PHP,但 Apache 无法加载扩展。
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.
Windows 7 (64bit) 和 xampp,我有 php 版本 5.4.7 我已经设置了 postgres,其他应用程序可以访问数据库。
When I uncomment the following lines in my php.ini
当我在 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:
我在 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
[2013 年 6 月 22 日 13:15:22 UTC] PHP 警告:PHP 启动:无法加载动态库 'C:\xampp\php\ext\php_pdo_pgsql.dll' - Das angegebene Modul wurde nicht gefunden。在未知的第 0 行
But the path is correct, and the files are there.
但是路径是正确的,文件就在那里。
After some research, I added this line to my http.conf:
经过一番研究,我将此行添加到我的 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.
但是无论我把这条线放在哪里,apache-service 都不能再启动了。所以我删除了这条线。
I also tried to add these 2 paths to my PATH-Variable:
我还尝试将这 2 条路径添加到我的 PATH 变量中:
C:\Program Files\PostgreSQL.2\bin
C:\xampp\php\ext
Now the error changed to
现在错误改为
in Unknown on line 0
在未知的第 0 行
Everything is running on the same, local machine. And using Linux / seperate servers is not an alternative.
一切都在同一台本地机器上运行。并且使用 Linux / 单独的服务器不是替代方案。
My phpinfo()
doesn't show any postgres-related things.
我的phpinfo()
没有显示任何与 postgres 相关的东西。
I hope someone knows how to solve the problem, Google didn't help me at all.
我希望有人知道如何解决这个问题,谷歌根本没有帮助我。
回答by maja
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)
我重新安装了 xampp 和 postgres,但使用了 postgres 32 位版本(64 位版本也应该有效,但我想确保)
Then I enabled the extensions in php.ini
again:
然后我php.ini
再次启用了扩展:
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).
我收到文件未再次找到的错误 (php_error_log)。
After reading this:
阅读本文后:
I downloaded libpq.dll
from postgres 8.4 and copied it both in apache/bin and postgres/lib (replaced the dll from there).
我libpq.dll
从 postgres 8.4下载并将它复制到 apache/bin 和 postgres/lib(从那里替换了 dll)。
In my Path-Variable there's still C:\xampp\php\ext\
, but it should work without that part too.
在我的 Path-Variable 中仍然有C:\xampp\php\ext\
,但它也应该在没有那部分的情况下工作。
I worked on this problem for 3 days and I hope it will help others to get it up and running faster.
我在这个问题上工作了 3 天,我希望它能帮助其他人更快地启动和运行它。