PHP 未在 Windows 上加载 php_pgsql.dll
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/551734/
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
PHP not loading php_pgsql.dll on Windows
提问by Ross
PHP 5.2.8 is refusing to load php_pgsql.dll, with the following error:
PHP 5.2.8 拒绝加载php_pgsql.dll,出现以下错误:
Warning: PHP Startup: Unable to load dynamic library 'D:\PHP\ext\php_pgsql.dll' - The specified module could not be found.
in Unknown on line 0
警告:PHP 启动:无法加载动态库 'D:\PHP\ext\php_pgsql.dll' - 找不到指定的模块。
在未知的第 0 行
The .dll exists in PHP/ext/.
.dll 存在于 PHP/ext/ 中。
Has anyone else had this problem with PHP on Windows before?
以前有没有其他人在 Windows 上遇到过 PHP 的这个问题?
回答by Mac
Check out the info on the PHP PostgreSQL installation page: http://us.php.net/manual/en/pgsql.installation.php
查看 PHP PostgreSQL 安装页面上的信息:http: //us.php.net/manual/en/pgsql.installation.php
On a Windows server, configured with Apache, adding the following line to httpd.conf to load libpq.dll can save you a lot of time :
LoadFile "C:/Program Files/PostgreSQL/8.4/bin/libpq.dll"Note that you will have to change your folder accordingly to the installation path and version of PostgreSQL you have installed. Also note that having Apache and PostgreSQL on the same server for production environments is not recommended.
在配置了 Apache 的 Windows 服务器上,在 httpd.conf 中添加以下行以加载 libpq.dll 可以为您节省大量时间:
LoadFile "C:/Program Files/PostgreSQL/8.4/bin/libpq.dll"请注意,您必须根据已安装的 PostgreSQL 的安装路径和版本相应地更改您的文件夹。另请注意,不建议在生产环境的同一服务器上使用 Apache 和 PostgreSQL。
This fixed my setup instantly.
这立即修复了我的设置。
回答by Dayron Armas Pe?a
This happened to me also with PHP 5.4.1
这也发生在我身上,PHP 5.4.1
Copying the offending DLL everywhere didn't work, and I don't have PostgreSQL installed in the server, but I also planned to use PHP against different Postgres versions, so the only solution I found that worked was to put in httpd.conf a line like this:
在任何地方复制有问题的 DLL 都不起作用,而且我没有在服务器中安装 PostgreSQL,但我也计划针对不同的 Postgres 版本使用 PHP,所以我发现唯一有效的解决方案是在 httpd.conf 中放入像这样的行:
LoadFile "C:/Program Files/PostgreSQL/8.4/bin/libpq.dll"
And referring to the libpq.dll that comes bundled with PHP, like this:
并参考 PHP 附带的 libpq.dll,如下所示:
LoadFile "C:/php/libpq.dll"
After that it worked fine to me.
在那之后,它对我来说效果很好。
回答by Marcovecchio
For those willing to make their PHP install only capable to access PostGres servers, without actually installing PostGres, you need to:
对于那些愿意让他们的 PHP 安装仅能够访问 PostGres 服务器而不实际安装 PostGres 的人,您需要:
- enable php_pgsql.dll (and php_pdo_pgsql.dll, if using PDO) extension in PHP.INI,
- make sure libpq.dll, libiconv-2.dll and libintl-8.dll are in the path. These are the php_pgsql.dll dependencies.
- 在 PHP.INI 中启用 php_pgsql.dll(和 php_pdo_pgsql.dll,如果使用 PDO)扩展,
- 确保 libpq.dll、libiconv-2.dll 和 libintl-8.dll 在路径中。这些是 php_pgsql.dll 依赖项。
These 3 DLLs can be found in the PostGres install. I just copied them into apache\bin, that way I keep everything self contained. Doing that, apache can start the PHP engine just fine, with PostGres support.
这 3 个 DLL 可以在 PostGres 安装中找到。我只是将它们复制到 apache\bin 中,这样我就可以保留所有内容。这样做,apache 可以很好地启动 PHP 引擎,并支持 PostGres。
回答by Milen A. Radev
The problem is with the related libraries used by php_pgsql.dll - like libpq.dll, the OpenSLL ones etc. You need to find them (from the zip distribution of Postgres, from an installed psqlODBC driver etc.) and put them in a folder which is in the PATH. As for the list of all DLLs - use MS Dependency Walker (depends.exe).
问题在于 php_pgsql.dll 使用的相关库 - 如 libpq.dll、OpenSLL 等。您需要找到它们(从 Postgres 的 zip 分发,从已安装的 psqlODBC 驱动程序等)并将它们放在一个文件夹中这是在路径中。至于所有 DLL 的列表 - 使用 MS Dependency Walker (depends.exe)。
Another important bit - Apache (if you use Apache that is) has its own set of OpenSSL DLLs. Replace or just rename those so to not clash with those from the Postgres distribution.
另一个重要的一点 - Apache(如果您使用的是 Apache)有它自己的 OpenSSL DLL 集。替换或只是重命名它们,以免与 Postgres 发行版中的那些发生冲突。
回答by Newcss
You need to copy libpq.dll from wamp\bin\php\php5.3.5 to wamp\bin\apache\Apache2.2.17\bin. Again restart the Wamp Server. By now we are done with the php configuration. Next we will install phpPgAdmin and use it.
您需要将 libpq.dll 从 wamp\bin\php\php5.3.5 复制到 wamp\bin\apache\Apache2.2.17\bin。再次重新启动 Wamp 服务器。至此,我们已经完成了 php 配置。接下来我们将安装 phpPgAdmin 并使用它。
回答by Rytmis
Just a thought -- make sure that the Postgres binaries are in the SYSTEM path, not your user-specific path. As it happens, that was the problem on my machine. :-)
只是一个想法 - 确保 Postgres 二进制文件位于 SYSTEM 路径中,而不是您特定于用户的路径中。碰巧,那是我机器上的问题。:-)
Edit:
编辑:
Come to think of it, that explains why Dependency Walker would report all A-OK but the problem would still persist -- you run DW under your own account, while Apache runs as SYSTEM, and hence won't have your personal PATH settings available.
想想看,这解释了为什么 Dependency Walker 会报告所有 A-OK 但问题仍然存在——您在自己的帐户下运行 DW,而 Apache 以 SYSTEM 身份运行,因此您的个人 PATH 设置将不可用.
回答by BARON'S
Just to share what worked for me, without dealing with libpq.dll. I uncommented both extension=php_pdo_pgsql.dlland extension=php_pgsql.dllin php.ini. At first, apache refused to start.
只是分享对我有用的东西,而不处理libpq.dll. 我在 php.ini 中取消了extension=php_pdo_pgsql.dll和 的注释extension=php_pgsql.dll。起初,apache拒绝启动。
I then add "C:\Program Files (x86)\PostgreSQL\9.4\bin\"(depending on your installation) into windows environment PATH, started apache successfully and works.
然后我将"C:\Program Files (x86)\PostgreSQL\9.4\bin\"(取决于您的安装)添加到 Windows 环境 PATH 中,成功启动 apache 并运行。
回答by danjah
Specifically for WAMP server setups here, you need to copy the libpg.dll file into "C:\wamp\bin\apache\Apache2.2.21\bin\", or similar. Copying it to ..\php\ext\ and also adjusting the PATH env variable simply wasn't enough (if effective at all).
特别是对于此处的 WAMP 服务器设置,您需要将 libpg.dll 文件复制到“C:\wamp\bin\apache\Apache2.2.21\bin\”或类似文件中。将它复制到 ..\php\ext\ 并调整 PATH 环境变量是不够的(如果有效的话)。
Original answer sourced here: http://www.wampserver.com/phorum/read.php?2,40270,57932
原始答案来源:http://www.wampserver.com/phorum/read.php? 2,40270,57932
Specifically for XAMPP setups, I found that I only needed to copy the libpg.dll file into ..\php\ext\ directory.
特别是对于 XAMPP 设置,我发现我只需要将 libpg.dll 文件复制到 ..\php\ext\ 目录中。
回答by juku
As Ond?ej Bouda mentioned: Setting up Windows environment variables is enough. No copies of dlls, no entries to http-conf. Just add the php-directory (C:\xampp\php) to PATH. Don't forget to restart XAMPP-Control-Panel if you use this, otherwise it won't know the changes. (And restart Apache of cause.)
正如 Ond?ej Bouda 提到的:设置 Windows 环境变量就足够了。没有 dll 的副本,也没有 http-conf 的条目。只需将 php 目录 (C:\xampp\php) 添加到 PATH。如果您使用它,请不要忘记重新启动 XAMPP-Control-Panel,否则它不会知道更改。(并出于原因重新启动Apache。)
For instance, on XAMPP, it was sufficient to put the PHP directory (i.e., C:\xampp\php) to the system PATH variable. – Ond?ej Bouda
例如,在 XAMPP 上,将 PHP 目录(即 C:\xampp\php)放到系统 PATH 变量中就足够了。– Ond?ej Bouda
回答by srikanth
This is an update to @Dayron Armas Pe?a 's answer. The php bundled pgsql 'dll' is found in the following location:
这是对@Dayron Armas Pe?a 的回答的更新。php 捆绑的 pgsql 'dll' 位于以下位置:
LoadFile "C:/wamp/bin/php/php5.4.12/libpq.dll"
Adding the above line to the httpd.conffile apart from uncommenting the required lines in the php.inifiles has solved my problem.
httpd.conf除了取消注释文件中所需的行之外,将上述行添加到php.ini文件中解决了我的问题。

