18
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Posted at

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

#  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

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?