参考サイト



(1)このあたりから落としてきます
http://www.postgresql.jp/PostgreSQL

(2)おとしてきたpostgresql-8.2.6.tar.gzを以下に配置
/usr/local/src

(3)rootでログイン後移動
cd /usr/local/src

(4)解凍
tar zxf postgresql-8.2.6.tar.gz

(5)移動
cd postgresql-8.2.6

(6)javaオプションと日本語オプションつけてmake
./configure --enable-multibyte=EUC_JP --with-java

make all

(7)インストールの実行(/usr/local/pgsql にインストールされる)
make install

↓という風にでればOK
All of PostgreSQL is successfully made. Ready to install

(8)ポスグレユーザーの生成(基本はrootのみ)
useradd postgres

(9)ポスグレユーザーに権限付与
chown postgres.postgres -R /usr/local/pgsql

(10)ポスグレユーザーの環境変数設定
su - postgres
vi ~/.bash_profile

↓の設定にする
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
       . ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
PATH=$PATH:/usr/local/pgsql/bin
export PATH
unset USERNAME
export POSTGRES_HOME=/usr/local/pgsql
export PGLIB=$POSTGRES_HOME/lib
export PGDATA=$POSTGRES_HOME/data
export MANPATH="$MANPATH":$POSTGRES_HOME/man
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":"$PGLIB"

(11)DB初期化
su - postgres
initdb --encoding=EUC_JP

↓こういうのが出ればOK
Success. You can now start the database server using:
/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data
or
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data start

(12)DB起動
pg_ctl -o "-i" start
※Sオプションは8.2から不要

(13)アクセス制限
  • pg_hba.confを編集
su - postgres
vi /usr/local/pgsql/data/pg_hba.conf
最終行に以下を追加(内部からのアクセスを許可)
host  all  all 192.168.1.1  255.255.255.255  trust

最終更新:2008年05月28日 14:49