无法在AWS中安装postgres

时间:2015-07-18 14:50:39

标签: ruby-on-rails postgresql amazon-web-services

我正在尝试从Heroku迁移到AWS

我创建了一个包含以下自定义JSON的堆栈:

{
  "deploy": {
    "appname": {
      "database": {
        "username": "myuser",
        "password": "password",
        "database": "databasename",
        "host": "rdsendpoint",
        "port": "5432",
        "adapter": "postgresql"
      }
    }
  }
}

我创建了一个RDS postgres DB和一个Rails App Server。我创建了一个实例和一个链接到我的git存储库的应用程序。

但实例无法启动,我收到此错误消息:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.


/usr/local/bin/ruby 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.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/bin/ruby
--with-pg
--without-pg
--enable-windows-cross
--disable-windows-cross
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/

extconf failed, exit code 1

Gem files will remain installed in /home/deploy/.bundler/authorship/ruby/2.0.0/gems/pg-0.18.2 for inspection.
Results logged to /home/deploy/.bundler/authorship/ruby/2.0.0/extensions/x86_64-linux/2.0.0/pg-0.18.2/gem_make.out
An error occurred while installing pg (0.18.2), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.2'` succeeds before bundling.

如何在AWS上修复此问题,因为我无法通过ssh访问该实例,因为它无法启动。

我尝试在图层中添加postgres-devel包,但是我遇到了一个不同的错误,似乎该包不再可用。

1 个答案:

答案 0 :(得分:3)

由于实例没有此包libpq-dev执行

sudo apt-get install libpq-dev

这样就可以安装pg gem。

以下是libpq-dev的描述:

  

用于编译要链接的C程序的头文件和静态库   使用libpq库以便与PostgreSQL进行通信   数据库后端。

pg gem是一个包装libpq库的本机扩展。

P.S我最近遇到了这个问题,我得到了其他组的一些解释。