使用远程Postgres数据库安装Postgres Gem PG

时间:2013-02-05 18:50:32

标签: ruby-on-rails-3 postgresql rubygems

我刚刚在Debian Squeeze服务器上安装了Ruby 1.9和Rails 3的新副本。 Rails Web应用程序需要连接到远程Postgres数据库,所以我尝试安装Postgres适配器,但似乎安装程序正在寻找本地PostgreSQL数据库和配置不存在,因为Postgres数据库存在于不同的主机。

有人可以解释当实际的Postgres数据库位于不同的机器上时如何安装Postgres适配器吗?

由于

gem1.9.1 install pg


Building native extensions.  This could take a while...
ERROR:  Error installing pg:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9.1 extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again   with
--with-pg-config=/path/to/pg_config


checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***

Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

1 个答案:

答案 0 :(得分:1)

您的环境中缺少库。在尝试安装pg gem之前,请尝试安装所有这些 或者,如果所有lib都已安装且您仍然遇到相同的错误,请尝试使用上面显示错误的--with-pg-config命令安装指定postgres配置文件的gem。

gem install pg --with-pg-config=TYPE_HERE_YOUR_postgresql.conf_PATH