启用在Ubuntu 11.04服务器PostgreSQL的支持PHP [英] Enable PHP support for postgresql in Ubuntu 11.04 server

查看:128
本文介绍了启用在Ubuntu 11.04服务器PostgreSQL的支持PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了Apache2中PHP5的支持,一切都在那里工作。我已经安装PostgreSQL和我能够使用的终端连接到它,并执行SQL语句。

I've installed Apache2 with php5 support and everything works there. I've installed PostgreSQL and am able to connect to it using the terminal and execute SQL statements.

问题:我不能让我的PHP脚本和PostgreSQL数据库之间的有效连接。我已经安装了PHP5-pgsql的从仓库打包,但连接是行不通的。

PROBLEM: I can't get a working connection between my php scripts and the PostgreSQL database. I have installed the php5-pgsql packaged from the repositories, but the connection just won't work.

我收到以下错误信息:

PHP致命错误:调用未定义的函数pg_connect()在/var/www/[myfile].php线[X]

PHP Fatal Error: Call to undefined function pg_connect() in /var/www/[myfile].php on line [X]

我如何在Ubuntu 11.04启用对PostgreSQL的PHP​​5连接的支持?

How do I enable support for PostgreSQL connections in PHP5 in ubuntu 11.04?

编辑:经过phpinfo()函数并没有发现任何条目PostgreSQL的。我不知道为什么会这样,我没有安装PHP5-pgsql的包的Ubuntu 11.04。

Checked phpinfo() and found no entries for PostgreSQL. I don't know why that is so, I DID install php5-pgsql package for ubuntu 11.04.

下面是什么工作:我安装的Ubuntu软件仓库phpPgAdmin的。这不仅使供我一个很好的工具,现在,它也安装所需的软件包为PHP连接到PostgreSQL。

Here is what worked: I installed phppgadmin from the Ubuntu repositories. Not only does this make a nice tool available for me now, it also installed the needed packages for php to connect to postgresql.

在此之后,这一切都在连接参数。它不会连接到数据库在本地服务器上,直到我联接的在pg_connect定义的顺序连接主机,端口,数据库,用户和密码()。

After that, it was all in the connection parameters. It wouldn't connect to the database on the local server until I defined the connection host, port, database, user, and password in that order in pg_connect().

我仍然不知道为什么我自己安装的php5-pgsql的未启用从PHP的PostgreSQL的连接。在这个任何投入将是有益的。

I still don't know why installing php5-pgsql on my own didn't enable PostgreSQL connections from php. Any input on this would be helpful.

推荐答案

安装​​PHP5-pgsql的封装解决问题。 (根据版本... PHP4-pgsql的为PHP4)

Install the php5-pgsql package solves the problem. (depending on the version ... php4-pgsql for php4)

apt-get install php5-pgsql

记住要重新启动Apache。

Remember to restart Apache.

/etc/init.d/apache2 restart

- 请注意,这可能是很难,如果你不管理您的服务器

--Note that it might be hard if you do not administer your server.

这篇关于启用在Ubuntu 11.04服务器PostgreSQL的支持PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆