简体   繁体   中英

Unable to install postgres in AWS

I am trying to migrate from Heroku to AWS

I have created a stack with the following custom JSON:

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

I have created a RDS postgres DB and a Rails App Server. I have created an instance and an App linked to my git repository.

However the instance fails to start and I get this error message:

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.

How can I fix this on AWS, since I cannot access the instance through ssh as it fails to start.

I tried to add a postgres-devel package to the layer, but I got a different error, seems that the package is no longer available.

Since the instance doesn't have this package libpq-dev do

sudo apt-get install libpq-dev

So that pg gem can be installed.

Here's the description of libpq-dev:

Header files and static library for compiling C programs to link with the libpq library in order to communicate with a PostgreSQL database backend.

The pg gem is a native extension that wraps the libpq library.

PS I recently ran into this problem, I got some explanation on other group.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM