无法在 Centos 上安装 PG ruby​​gem

无法在 Centos 上安装 PG ruby​​gem

我试图gem install pg在我的 Centos VPS 上运行,但

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

    /usr/local/rvm/rubies/ruby-2.0.0-p247/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/rvm/rubies/ruby-2.0.0-p247/bin/ruby
    --with-pg
    --without-pg
    --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}/

我已经安装了 postgres 9.3,如您在此处所见(yum list installed | grep postgres

postgresql-libs.x86_64              8.4.13-1.el6_3                     @base
postgresql93.x86_64                 9.3.1-1PGDG.rhel6                  @pgdg93
postgresql93-devel.x86_64           9.3.1-1PGDG.rhel6                  @pgdg93
postgresql93-libs.x86_64            9.3.1-1PGDG.rhel6                  @pgdg93
postgresql93-server.x86_64          9.3.1-1PGDG.rhel6                  @pgdg93

答案1

尝试此解决方案并重新启动您的会话

export PATH="/usr/pgsql-9.3/bin:$PATH"

或者尝试

yum install libpqxx-devel
gem install pg -- --with-pg-config=/usr/pgsql-9.4/bin/pg_config

答案2

您可以使用 yum 安装 postgresql 库:

yum install postgresql-libs

这应该会安装所引用的库,以便您可以尝试再次安装 gem。

相关内容