为已安装的 PHP 添加 PostgreSQL 支持
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8181175/
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
Adding PostgreSQL support to already installed PHP
提问by Soumyajit De
I have php-5.3.6 and postgresql installed in my Fedora 13. But it seems that postgresql support is not enabled in php. My phpinfo() page doesn't show any PostgreSQL section, neither pdo_pgsql section.
我的 Fedora 13 中安装了 php-5.3.6 和 postgresql。但似乎在 php 中没有启用 postgresql 支持。我的 phpinfo() 页面没有显示任何 PostgreSQL 部分,也没有显示 pdo_pgsql 部分。
I checked /etc/php.ini, and it shows that PostgresSQL is enabled.
我检查了/etc/php.ini,它显示启用了PostgresSQL。
[root@localhost ~]# cat /etc/php.ini | grep ^pgsql
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0
Is there any way I can add postgresql support to php without recompiling it from the source? Is there any other files I need to make some changes?
有什么方法可以将 postgresql 支持添加到 php 而无需从源代码重新编译它?是否还有其他文件需要进行更改?
回答by Silas Parker
Run yum install php-pgsql php-pdo_pgsql
to install the PHP Postgres package.
运行yum install php-pgsql php-pdo_pgsql
以安装 PHP Postgres 包。
回答by iver56
Here's what solved the issue for me (on Windows, using WAMPSERVER):
这是为我解决问题的方法(在 Windows 上,使用 WAMPSERVER):
- Uncomment
extension=php_pgsql.dll
andextension=php_pdo_pgsql.dll
in php.ini - Restart all services in WAMPSERVER
- Make sure that php_pgsql and php_pdo_pgsql are checked in the WAMPSERVER menu -> PHP -> PHP extensions
- In httpd.conf add the line
LoadFile "C:/Program Files/PostgreSQL/9.4/bin/libpq.dll"
before the lineLoadModule php5_module "c:/wamp/bin/php/php5.5.12/php5apache2_4.dll"
- Restart all services again and check that the WAMPSERVER icon becomes green.
- 取消注释
extension=php_pgsql.dll
并extension=php_pdo_pgsql.dll
在 php.ini 中 - 重启 WAMPSERVER 中的所有服务
- 确保在 WAMPSERVER 菜单 -> PHP -> PHP extensions 中勾选了 php_pgsql 和 php_pdo_pgsql
- 在 httpd.conf 行
LoadFile "C:/Program Files/PostgreSQL/9.4/bin/libpq.dll"
前添加行LoadModule php5_module "c:/wamp/bin/php/php5.5.12/php5apache2_4.dll"
- 再次重新启动所有服务并检查 WAMPSERVER 图标是否变为绿色。
Source: http://toolkt.com/site/install-postgresql-and-phppgadmin-in-windows-with-wamp/
来源:http: //toolkt.com/site/install-postgresql-and-phppgadmin-in-windows-with-wamp/
回答by user28864
I had a similar problem earlier on today on Windows. I couldn't access "Phppgadmin". Whenever I tried to access it I get this error: "Your PHP installation does not support PostgreSQL. You need to recompile PHP using the --with-pgsql configure option". So I did some search which got me here.
我今天早些时候在 Windows 上遇到了类似的问题。我无法访问“Phppgadmin”。每当我尝试访问它时,我都会收到此错误:“您的 PHP 安装不支持 PostgreSQL。您需要使用 --with-pgsql 配置选项重新编译 PHP”。所以我做了一些搜索,这让我来到了这里。
Anyway, I was able find a way around the problem using the instruction I found hereas follows:
无论如何,我能够使用我在此处找到的说明找到解决问题的方法,如下所示:
- Browsed to the php.ini file found in C:\xampp\php\php.ini and opened it in text editor as an administrator
- Uncommented the following by removing the semicolons prefexing;
extension_dir="C:\xampp\php\ext"
,extension=php_pgsql.dll
andextension=php_pgsql.dll
- Saved the file and restarted Apache
- 浏览到 C:\xampp\php\php.ini 中的 php.ini 文件并以管理员身份在文本编辑器中打开它
- 通过删除分号前缀取消注释以下内容;
extension_dir="C:\xampp\php\ext"
,extension=php_pgsql.dll
和extension=php_pgsql.dll
- 保存文件并重新启动Apache
回答by naveen kumar
Similar problem I got earlier on Windows. I couldn't able to access "Phppgadmin". Whenever I access phppgadmin getting error: "Your PHP installation does not support PostgreSQL. You need to recompile PHP using the --with-pgsql configure option".
我之前在 Windows 上遇到过类似的问题。我无法访问“Phppgadmin”。每当我访问 phppgadmin 时都会出现错误:“您的 PHP 安装不支持 PostgreSQL。您需要使用 --with-pgsql 配置选项重新编译 PHP”。
Finally, got the solution.
终于,得到了解决方案。
You need to follow this path C:\xampp\php\php.ini and opened it in text editor as an administrator and remove the semicolons pre-fexing; extension_dir="C:\xampp\php\ext", extension=php_pgsql.dll and extension=php_pgsql.dll Saved the file and restarted Apache
你需要按照这个路径 C:\xampp\php\php.ini 并以管理员身份在文本编辑器中打开它并删除分号前缀;extension_dir="C:\xampp\php\ext", extension=php_pgsql.dll and extension=php_pgsql.dll 保存文件并重启Apache