LoginSignup
10
10

More than 5 years have passed since last update.

CentOS7.3にpostgresql9.5とPostGIS2.2.5-1インストール

Last updated at Posted at 2015-08-19

リポジトリ追加

・Postgresql


 $ sudo rpm -ivh https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-3.noarch.rpm

・EPEL


 # yum -y install epel-release

インストール

・Postgresql


 # yum -y install postgresql95 postgresql95-server postgresql95-libs postgresql95-contrib postgresql95-devel

・PostGIS
epelを有効にしてインストール


 # yum -y --enablerepo=epel install postgis2_95

起動

下記サイトを参考にしました。
CentOS7にPostgreSQL9.3と最新のもので環境構築してみた。

・環境変数設定


 $ sudo su postgres
[postgres]$ vi ~/.bash_profile

export PATH=$PATH:/usr/pgsql-9.5/bin # PostgreSQLのコマンドパスを設定
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/pgsql-9.5/lib # PostgreSQLの共有ライブラリを設定

[postgres]$ source ~/.bash_profile

・DBクラスタ初期化


[postgres]$ initdb --encoding=UTF8 --no-locale

・サーバプロセス起動


 # systemctl start postgresql-9.5.service

・自動起動設定
起動スクリプトは作成されるので、項目の修正が必要な場合には/etc/systemd/system/postgresql-9.5.serviceを作成して追記する。


 # vi /etc/systemd/system/postgresql-9.5.service

.include /lib/systemd/system/postgresql-9.5.service

・・・ここに追記・・・

# systemctl enable postgresql-9.5.service

以上

※2016/4/9追記内容:
・CentOS7.2で動作確認(タイトル7.1→7.2に変更)。
・自動起動設定で、/lib/systemd/system/postgresql-9.4.service を直接修正せず、/etc/systemd/system/postgresql-9.4.serviceを新規作成したうえで上記をインクルードし、変更したい項目だけ記述するように変更(コメントにて指摘いただきました)。
・タイトルにPostGISバージョンを記載。
・EPELリポジトリインストール方法をrpmからyumに変更。

※2017/4/10追記内容:
・CentOS7.3, PostgreSQL9.5, Postgis2.2.5-1に対応。

10
10
1

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
10
10