さくらVPSにPostgreSQL9.2とpg-gem(0.14.1)を入れる

herokuからお引越しをしようかなと画策中。
いくつか躓いたのでめもめも。

環境

さくらVPS (CentOS 5.5)

PostgreSQL9.2をインストール

デフォルトでyumにあるバージョンが低いので、
入れたいバージョンに合ったRPMリポジトリをDLしてきて、入れます。

# rpm -ivh pgdg-centos92-9.2-6.noarch.rpm 
# yum -y install postgresql92
# yum -y install postgresql92-devel

でインストール。

参考:http://wdsdx.com/yum_repo_pgdg

pg-gemをインストール

最終的にはこんなんでいけました。

$ gem install pg -v '0.14.1' -- --with-pg-include=/path/to/pg-include/ --with-pg-lib=/path/to/pg-lib/

以下に顛末を。


ふつうにgem installのみでは

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

        /usr/local/rvm/rubies/ruby-1.9.3-p429/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/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-1.9.3-p429/bin/ruby
	--with-pg
	--without-pg
	--with-pg-dir
	--without-pg-dir
	--with-pg-include
	--without-pg-include=${pg-dir}/include
	--with-pg-lib
	--without-pg-lib=${pg-dir}/lib
	--with-pg-config
	--without-pg-config
	--with-pg_config
	--without-pg_config

こう出たので、locate libpq-fe.hして出たパスを指定してあげたら

$  gem install pg -v '0.14.1' -- --with-pg-include=/usr/pgsql-9.2/include/

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

        /usr/local/rvm/rubies/ruby-1.9.3-p429/bin/ruby extconf.rb --with-pg-include=/usr/pgsql-9.2/include/
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** 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-1.9.3-p429/bin/ruby
	--with-pg
	--without-pg
	--with-pg-dir
	--without-pg-dir
	--with-pg-include=${pg-dir}/include
	--with-pg-lib
	--without-pg-lib=${pg-dir}/lib
	--with-pg-config
	--without-pg-config
	--with-pg_config
	--without-pg_config
	--with-pqlib
	--without-pqlib
	--with-libpqlib
	--without-libpqlib
	--with-ms/libpqlib
	--without-ms/libpqlib

まだだめ。

ゴチャマゼノオモチャバコ: さくらVPS(CentOS5.7)でRubyだDBIだdbd-pgだ などを見ながら
pgのライブラリパスを指定してあげたら、

$ gem install pg -v '0.14.1' -- --with-pg-include=/usr/pgsql-9.2/include/ --with-pg-lib=/usr/pgsql-9.2/lib/

Successfully installed pg-0.14.1
1 gem installed

できました:D