[英]Using postgresql with php under windows/xampp
I'm trying to use postgres
with PHP, but Apache can't load the extension. 我正在尝试使用PHP的
postgres
,但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. 带有xampp的Windows 7(64位),我有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.
[2013年6月22日13:15:22 UTC] PHP警告:PHP启动:无法加载动态库'C:\\ xampp \\ php \\ ext \\ php_pdo_pgsql.dll' - Das angegebene Modul wurde nicht gefunden。 in Unknown on line 0
在第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. 但是无论我把这条线放进去,apache-service都无法启动了。 So I removed the line.
所以我删除了这条线。
I also tried to add these 2 paths to my PATH-Variable: 我还尝试将这两个路径添加到我的PATH变量中:
C:\Program Files\PostgreSQL\9.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 / seperate服务器不是另一种选择。
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. 我希望有人知道如何解决问题,谷歌根本没有帮助我。
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 32bit-version(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: 看完之后:
http://postgresql.1045698.n5.nabble.com/pgAgent-installation-fails-LIBPQ-DLL-is-missing-PostgreSQL-9-0-2-x64-2008-Windows-Server-x64-td3351434.html 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). 我从postgres 8.4下载了
libpq.dll
并将其复制到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天,我希望它能帮助其他人更快地完成这项工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.