LoginSignup
1
2

More than 3 years have passed since last update.

AWS Cloud9上でPostgreSQLをソースからインストール

Posted at

概要

 AWS Cloud9 上でpostgreqlとdeviseを使ってRailsアプリを開発をしようとした際に、
postgresqlのバージョンが古いと怒られたのでやってみたことをメモ。

  • 環境
    • AWS Cloud9
      • Amazon Linux AMI release 2018.03
    • postgre
      • postgres (PostgreSQL) 9.2.24

ソースからコンパイル

下記を順に実行
一応コンパイラからインストール

$ sudo yum install -y gcc readline-devel zlib-devel
$ wget https://ftp.postgresql.org/pub/source/v10.4/postgresql-10.4.tar.gz
$ tar -xf postgresql-10.4.tar.gz
$ cd postgresql-10.4
$ ./configure
$ make -C src/bin

ここでエラーが出るのでMakefile内を下記のように修正する。

$ make -C src/bin
make: Entering directory `/home/ec2-user/postgresql-10.4/src/bin'
Makefile:14: ../../src/Makefile.global: No such file or directory
make: *** No rule to make target `../../src/Makefile.global'.  Stop.
make: Leaving directory `/home/ec2-user/postgresql-10.4/src/bin'

Makefileの14行目の'Makefile.global'のところが間違いで
'Makefile.global.in'に訂正すると無事にmakeできます。そのまま続きへ、

$ sudo make -C src/bin install
$ make -C src/include
$ sudo make -C src/include install
$ make -C src/interfaces
$ sudo make -C src/interfaces install
$ make -C doc
$ sudo make -C doc install

以上でエラーが出なければインストールは完了。
今回インストールされた場所は/usr/local/pgsql/bin/psqlなのでそこにパスを通します。

$ vi ~/.bash_profile

として最後の行に

export PATH="/usr/local/pgsql/bin:$PATH"

を追加して保存。

$ source ~/.bash_profile

これで完了。

バージョンを確認する

$ psql --version
psql (PostgreSQL) 10.4

10.4になってます。

因みに、これをアンインストールするにはmakeした場所で、

$ make uninstall

とすると消える。

参照

How To Completely Uninstall PostgreSQL
Installing PostgreSQL Client v10 on AWS Amazon Linux (EC2) AMI
make installしたソフトウェアをアンインストールする

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2