search
LoginSignup
18
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at

postgresインストール(ソースから)

コンパイルに必要なライブラリをインストール

#  yum install readline-devel
#  yum install zlib-devel

postgresユーザ作成

# useradd postgres
# su - postgres

環境変数定義

/home/postgres/.zshrc.mine
export PGHOME=/usr/local/pgsql
export PGDATA=/usr/local/pgsql/data
export PGHOST=localhost
PATH=$PGHOME/bin:$PATH
$ source ~/.zshrc

環境によって.bashrcなどに。

postgresインストール

$ mkdir ~/src && cd ~/src
$ wget "http://ftp.postgresql.org/pub/source/v9.3.1/postgresql-9.3.1.tar.gz"
$ tar xvzf postgresql-9.3.1.tar.gz
$ cd postgresql-9.3.1
$ ./configure
$ make
$ make check
$ sudo make install

initdb

$ sudo mkdir /usr/local/pgsql/data
$ sudo chown postgres:postgres /usr/local/pgsql/data
$ initdb --encoding=UNICODE

起動してみる

$ pg_ctl start
$ psql -l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | ja_JP.UTF-8 | ja_JP.UTF-8 |
 template0 | postgres | UTF8     | ja_JP.UTF-8 | ja_JP.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | ja_JP.UTF-8 | ja_JP.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
(3 rows)

$pg_ctl stop

設定ファイル編集

/usr/local/pgsql/data/postgresql.conf
listen_addresses = '*'
/usr/local/pgsql/data/pg_hba.conf
#外からはパスワード認証
host    all             all             0.0.0.0/0            password

起動スクリプト設定

$ su -
# cp /home/postgres/src/postgresql-9.3.1/contrib/start-scripts/linux /etc/rc.d/init.d/postgres
# chmod 755 /etc/rc.d/init.d/postgres
# /etc/rc.d/init.d/postgres start

環境

CentOS6.4 (さくらのVPS)
PostgreSQL9.3

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
What you can do with signing up
18
Help us understand the problem. What are the problem?