Heroku Postgres从本地PHP应用程序连接 [英] Heroku Postgres Connection from localhost PHP application

查看:203
本文介绍了Heroku Postgres从本地PHP应用程序连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论如何,从本地运行的PHP应用程序连接到Heroku postgres(Free)数据库实例。我能够成功连接pgAdminIII,但通过连接到同一个Db的应用程序连接字符串没有运气?



连接

  $ dbconn = pg_connect(host = xxxxxx.compute-1.amazonaws.com port = 5432 dbname = xxxxxxx user = xxxxxx password = xxxxxx sslmode = require options =' -  client_encoding = UTF8' ); 

PHP代码引发的错误:

 警告:pg_connect():无法连接到PostgreSQL服务器:sslmode值& quot; require& quot;无法在
中编译SSL支持时无效

我在Heroku的网站上发现了以下内容,但我希望有人可以澄清我是否正在处理postgres php问题(在Apache上运行PHP,在Mac OS X Lion 10.7.4上运行PHP 5.3),或者如果这只是Heroku的以下声明中指出的环境限制:


如何连接到Heroku Postgres? Heroku上的数据库Postgres
接受标准的PostgreSQL连接。可以从
PostgreSQL客户端应用程序(例如psql或PGAdmin),应用程序
框架(例如Ruby-on-Rails或Django)或任何其他libpq
兼容客户端进行连接,然后从SSL上的任何地方访问。



然而,共享数据库只能连接到运行在Heroku上的应用程序




有人可以解释为什么pgAdminIII能够连接,但我的应用程序cannont?

谢谢。



进一步发现:
PHPINFO - >




  • 支持OpenSSL

  • OpenSSL库版本OpenSSL 0.9.8r 2月8日
    2011

  • OpenSSL标题版本OpenSSL 0.9.8r 2011年2月8日


  • 启用PostgreSQL支持


  • PostgreSQL(libpq)版本8.2.23
  • em> 禁用SSL支持

我与一位代表谈话在Heroku tative。他们向我确认,它不需要任何特定层级的帐户连接到Heroku Postgres数据库,唯一的规定是连接在远程连接时使用ssl。所以我的问题是pgsql在我的PHP版本中没有ssl支持的结果。


Is there anyway to connect to the Heroku postgres (Free) db instance from a locally running PHP application. I am able to get pgAdminIII successfully connected, but no luck through application connection string connecting to the same Db?

Connection

$dbconn = pg_connect("host=xxxxxx.compute-1.amazonaws.com port=5432 dbname=xxxxxxx user=xxxxxx password=xxxxxx sslmode=require options='--client_encoding=UTF8'");

Error Thrown from PHP Code:

 Warning: pg_connect(): Unable to connect to PostgreSQL server: sslmode value "require" invalid when SSL support is not compiled in in 

I found the following on Heroku's site but I am hoping someone can clarify whether I'm dealing with a postgres php issue (running PHP on Apache, PHP 5.3 on Mac OS X Lion 10.7.4) or if this is just an environment restriction as indicated in Heroku's following statement:

How do I connect to Heroku Postgres? Databases on Heroku Postgres accept standard PostgreSQL connections. Connections can be made from PostgreSQL client applications (such as psql, or PGAdmin), Application Frameworks (such as Ruby-on-Rails or Django), or any other libpq compatible client, from anywhere over SSL.

Shared databases however, can only be connected to from applications running on Heroku.

Can someone also explain why pgAdminIII is able to connect but my application cannont?

Thank you.

Further Findings: PHPINFO->

  • OpenSSL support enabled
  • OpenSSL Library Version OpenSSL 0.9.8r 8 Feb 2011
  • OpenSSL Header Version OpenSSL 0.9.8r 8 Feb 2011

  • PostgreSQL Support enabled

  • PostgreSQL(libpq) Version 8.2.23
  • SSL support disabled

解决方案

So I spoke with a representative at Heroku. They confirmed for me that it does not require any specific tier of account to connect to a Heroku Postgres database, the only stipulation is that the connection uses ssl when connecting remotely. So my issue is the result of pgsql not having ssl support in my build of php.

这篇关于Heroku Postgres从本地PHP应用程序连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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