Azure:Rails和PostgreSQL在同一个VM上?

时间:2017-01-22 10:43:39

标签: ruby-on-rails postgresql azure virtual-machine

我试图在同一个Azure虚拟机上组合Rails应用程序和PostgreSQL。 我在this guide之后安装了PostgreSQL 9.5,它本身似乎没有任何问题。现在问题是,我无法安装pg gem。具体来说,运行命令gem install pg -v '0.19.0',它会给我以下错误:

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

current directory: /var/lib/gems/2.3.0/gems/pg-0.19.0/ext
/usr/bin/ruby2.3 -r ./siteconf20170122-18144-1ee3id1.rb extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
You need to install postgresql-server-dev-X.Y for building a server-side     extension or libpq-dev for building a client-side application.
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
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/bin/$(RUBY_BASE_NAME)2.3
        --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}/lib

To see why this extension failed to compile, please check the mkmf.log which      can be found here:

  /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/pg-0.19.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.3.0/gems/pg-0.19.0 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/pg-0.19.0/gem_make.out

非常感谢任何帮助。干杯

2 个答案:

答案 0 :(得分:0)

which pg_config

的回复是什么?

如果是这样的话:

/ usr / bin / which:no pg_config in ...

尝试使用以下命令再次安装:

sudo apt-get install postgresql-devel

答案 1 :(得分:0)

就像它一样简单,我只需要在我的Azure Ubuntu VM上安装postgresql-server-dev-9.5。我只是忽略了错误日志:D