LoginSignup
3
4

More than 5 years have passed since last update.

PostgreSQLをDebian GNU Linuxでbuildする

Last updated at Posted at 2014-07-03

PostgreSQLをDebian GNU Linux でソースコードからビルドする方法

ソースコードをダウンロードする。

ここから9.3.5をダウンロード
http://www.postgresql.org/ftp/source/

必要な開発者用ファイルをインストールしてconfigure & make install

 apt-get やmakeが出来る権限のユーザーで次のコマンドを実行。

pgbuild.sh
#開発者用ライブラリをインストール
apt-get install -y libkrb5-dev libssl-dev libxml2-dev libxslt1-dev \
    libossp-uuid-dev libedit-dev libgssapi-krb5-2 libldap2-dev \
    python2.7-dev libperl-dev

bzip2 -dc postgresql-9.3.5.tar.bz2 | tar xf - 

echo "plz comment out KEEPONLYALNUM"

nano postgresql-9.3.5/contrib/pg_trgm/trgm.h

#ビルド

cd postgresql-9.3.5

./configure \
    --with-includes=/usr/local/include \
    --with-includes=/usr/include/mit-krb5 \
    --with-includes=/usr/include/python2.7 \
    --with-libs=/usr/lib \
    --with-libs=/usr/local/lib \
    --with-libs=/usr/lib/x86_64-linux-gnu \
    --with-gssapi --with-krb5 --with-openssl \
    --with-pam --with-ldap \
    --with-libxml --with-libxslt --with-ossp-uuid --with-python \
    --with-perl --with-readline --with-libedit-preferred \
    -enable-nls='Japanese' \
    ARCHFLAGS='-arch x86_64'

make check
make install #インストール

#所々の設定
adduser postgres
mkdir /usr/local/pgsql/data
chown postgres:postgres /usr/local/pgsql/data
initdb

#スタートスクリプトの設定
cp ./contrib/start-scripts/linux /etc/init.d/postgres
chmod 755 /etc/init.d/postgres

#PostgreSQLサーバーのデーモンをスタート
/etc/rc.d/init.d/postgres start

以上、一発で通るか分かりませんが、順序良くこれらを実行していけば無事にビルドできるはず。

pg-trgmを使って日本語全文検索をしたい人へ

 PostgreSQLをソースコードからビルドする目的はおそらくこれだけだろう。pg-trgmはデフォルトの設定でビルドされたバイナリだと日本語検索が正しくされないからだ。よって ”contrib/pg_trgm/trgm.hの#define KEEPONLYALNUMをコメントアウト” する。
 その後、前述のconfigure & makeを行えばOKである。

via

終わりに

 個人用のメモ感覚で書いたのでなにか分かりにくい所、間違っている所があればコメントなどで……。

3
4
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
3
4