patorashのブログ

方向性はまだない

Amazon Linux 1にPostgreSQL 11をインストールする

まず、PostgreSQLyumリポジトリを追加します。 参照先は以下。

yum.postgresql.org

Amazon Linux 1はRedHat Enterprise Linux6互換(?)のため、そのURLをコピーして追加します。そのあと、/etc/yum.repos.d/pgdg-11-redhat.repoに記載されているURLをsedで置換します。

$ sudo yum install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-6-x86_64/pgdg-redhat11-11-2.noarch.rpm
$ sudo sed -i "s/rhel-\$releasever-\$basearch/rhel-6.10-x86_64/g" "/etc/yum.repos.d/pgdg-11-redhat.repo"

あとは、インストールするだけ。クライアントだけ欲しかったのでpostgresql11, postgresql11-develのみを指定しています。

$ sudo yum install -y postgresql11 postgresql11-devel

psqlのバージョンを確認して終わり。

$ psql --version
psql (PostgreSQL) 11.2

2019-03-08 追記

gem pgのインストールでこけた…。pg_configが見つからないと言われた。

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

    current directory: /home/heroku/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/pg-1.1.4/ext
/home/heroku/.rbenv/versions/2.5.3/bin/ruby -r ./siteconf20190307-22703-1t1ti1k.rb 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
# .bash_profile
need configuration options.

/usr/pgsql-11/binにPATHを通せばいいことがわかった。

bitarts.jp

.bash_profileを編集する。

PATH=$PATH:/usr/pgsql-11/bin
export PATH

source ~/.bash_profileしてから、bundle installしたら成功した。