- Ekstrak file
[root@localhost]$ tar xvf postgresql.tar.gz
- Masuk ke folder hasil ekstrak
[root@localhost]$ cd postgresql_folder
- Konfigurasi
[root@localhost postgresql_folder]$ ./configure
Jika ada error readline
dan zlib
, tambahkan menggunakan yum
Atau jika tidak memakai paket tersebut, bisa tambahkan parameter berikut.[root@localhost postgresql_folder]$ ./configure --without-readline --without-zlib
- Make dan make install
[root@localhost postgresql_folder]$ make
[root@localhost postgresql_folder]$ make install
- Tambahkan PATH dan PGDATA
[root@localhost]$ cd
[root@localhost]$ vim .bash_profile
export PATH=/usr/local/pgsql/bin:$PATH
export PGDATA=/usr/local/pgsql/data
- Buat user sendiri untuk postgres
[root@localhost]$ adduser postgres
- Ubah owner folder instalasi
[root@localhost]$ chown -R /usr/local/pgsql
- Buat folder data
[root@localhost]$ mkdir /usr/local/pgsql/data
- Sebelumnya, exit user agar variabel environment tadi bekerja
[root@localhost]$ exit
- Inisialisasi database
[root@localhost]$ initdb -D $PGDATA
- start database
[root@localhost]$ pg_ctl -D $PGDATA start
- Buat otomatisasi start database on-boot.
[root@localhost]$ cd postgresql_folder #folder hasil ekstrak
[root@localhost postgresql_folder]$ cd contrib/start-scripts
[root@localhost postgresql_folder]$ cp linux /etc/init.d
[root@localhost init.d]$ cd /etc/init.d
[root@localhost init.d]$ mv linux postgresql
[root@localhost init.d]$ chmod +x postgresql
[root@localhost init.d]$ chkconfig --add postgresql
[root@localhost init.d]$ chkconfig --list postgresql #cek apakah sudah on
- Ubah konfigurasi agar bisa diakses dari klien
[root@localhost]$ vim $PGDATA/postgresql.conf
(hapus tanda # atau uncomment)
listen_addresses = *
[root@localhost]$ vim $PGDATA/pg_hba.conf
(tambahkan)
HOST ALL ALL ip_klien/32 trust
- Konfigurasi firewall untuk port PostgreSQL 5432 atau matikan saja