Kamis, 11 September 2014

Instalasi & Konfigurasi Awal Database Server PostgreSQL 9.3 di CentOS 6.5 Minimal Server

__________________________________


TERIMA KASIH TELAH BERKUNJUNG TEMAN !
SEBELUM MELANJUTKAN MEMBACA, TOLONG SUBSCRIBE KE CHANNEL YOUTUBE SAYA YA KAWAN.
CARANYA KLIK TOMBOL MERAH DIATAS.

____________________________________________________________________________________________________________________________________
________________________




Kali ini kita akan melakukan instalasi dan konfigurasi awal database server postgresql 9.3 di CentOS 9.3. Ikuti langkah-langkah berikut ini.
  1. Instalasi
  2. Sementara matikan terlebih dahulu service iptable untuk kemudahan proses koneksi ke database nantinya. Kemudian cek versi CentOS menggunakan perintah berikut ini.

    [root@PostgreSQL-50G ~]# cat /etc/centos-release 
    CentOS release 6.5 (Final)
     
    [root@PostgreSQL-50G ~]# cat /etc/redhat-release 
    CentOS release 6.5 (Final)
     
    [root@PostgreSQL-50G ~]# uname -a
    Linux PostgreSQL-50G 2.6.32-431.29.2.el6.x86_64 #1 SMP Tue Sep 9 21:36:05 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
     
    [root@PostgreSQL-50G ~]# uname -r
    2.6.32-431.29.2.el6.x86_64
    

    Tambahkan PostgreSQL Yum Repository, kemudian update database repository :

    [root@PostgreSQL-50G ~]# yum install http://yum.postgresql.org/9.3/redhat/rhel-6.4-x86_64/pgdg-centos93-9.3-1.noarch.rpm
    [root@PostgreSQL-50G ~]# yum update
    

    Install PostgreSQL 9.3 :

    [root@PostgreSQL-50G ~]# yum install postgresql93-server postgresql93-contrib
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: repo.apiknet.co.id
    .
    .
    .
    
    Total download size: 6.2 M
    Installed size: 25 M
    Is this ok [y/N]: y
    .
    .
    .
    Installed:
      postgresql93-contrib.x86_64 0:9.3.5-1PGDG.rhel6                            postgresql93-server.x86_64 0:9.3.5-1PGDG.rhel6                           
    
    Dependency Installed:
      libxslt.x86_64 0:1.1.26-2.el6_3.1  postgresql93.x86_64 0:9.3.5-1PGDG.rhel6  postgresql93-libs.x86_64 0:9.3.5-1PGDG.rhel6  uuid.x86_64 0:1.6.1-10.el6 
    
    Complete!
    

    Inisialisasi database postgresql menggunakan perintah berikut.

    [root@PostgreSQL-50G ~]# service postgresql-9.3 initdb
    Initializing database:                                     [  OK  ]
    

    Start service postgresql dan buat agar service tersebut start secara otomatis setiap kali komputer reboot.

    [root@PostgreSQL-50G ~]# /etc/init.d/postgresql-9.3 start
    Starting postgresql-9.3 service:                           [  OK  ]
    
    [root@PostgreSQL-50G ~]# chkconfig postgresql-9.3 on
    

    Tahap instalasi sudah selesai sampai disini.
    Proses instalasi akan secara otomatis membuat user "postgres".

    [root@PostgreSQL-50G ~]# cat /etc/passwd | grep postgres
    postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash
    


  3. Konfigurasi Awal
    Perhatikan bahwa 'user database' berbeda dengan user dalam sistem Linux. User dalam sistem Linux dipakai untuk login ke dalam sistem operasi Linux, sedangkan user database digunakan untuk login ke dalam server PostgreSQL. Pertama-tama kita akan memberi password pada user postgres.

    [root@PostgreSQL-50G ~]# passwd postgres
    Changing password for user postgres.
    New password: 
    Retype new password: 
    passwd: all authentication tokens updated successfully.
    

    Untuk mengakses postgresql dari local komputer, cukup berganti saja sebagai user "postgres" kemudian masuk ke postgresql prompt.

    [root@PostgreSQL-50G ~]# su - postgres
    -bash-4.1$ psql
    psql (9.3.5)
    Type "help" for help.
    
    postgres=# 
    

    Buat password untuk user "postgres".

    postgres=# \password postgres 
    Enter new password: 
    Enter it again:
    

    Untuk menginstall PostgreSQL Adminpack, gunakan perintah di bawah ini.

    postgres=# CREATE EXTENSION adminpack;
    CREATE EXTENSION
    

    Untuk keluar dari postgresql prompt gunakan perintah berikut.

    postgres=# \quit
    -bash-4.1$ \exit
    logout
     
    [root@PostgreSQL-50G ~]# 
    

    Buat user baru dengan perintah berikut ini.
    [root@PostgreSQL-50G ~]# su - postgres
    -bash-4.1$ createuser user_postgre1
    

    Buat database baru.

    -bash-4.1$ createdb dbgue
    

    Set password untuk user "user_postgre1" dan berikan akses ke database "dbgue".

    postgres=# alter user user_postgre1 with encrypted password '12345678';
    ALTER ROLE
    
    postgres=# \list
                                      List of databases
       Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
    -----------+----------+----------+-------------+-------------+-----------------------
     dbgue     | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
     postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
     template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
               |          |          |             |             | postgres=CTc/postgres
     template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
               |          |          |             |             | postgres=CTc/postgres
    (4 rows)
    
    postgres=# grant all privileges on database dbgue to user_postgre1;
    GRANT
    

    Untuk menghapus user "user_postgre1" dan menghapus database "dbgue", gunakan perintah berikut.

    postgres=# \q
    -bash-4.1$ dropdb dbgue
    -bash-4.1$ dropuser user_postgre1
    -bash-4.1$ psql
    psql (9.3.5)
    Type "help" for help.
    
    postgres=# \list
                                      List of databases
       Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
    -----------+----------+----------+-------------+-------------+-----------------------
     postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
     template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
               |          |          |             |             | postgres=CTc/postgres
     template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
               |          |          |             |             | postgres=CTc/postgres
    (3 rows)
    
    postgres=# \q
    -bash-4.1$ \exit
    logout
    
    [root@PostgreSQL-50G ~]# 
    


    Untuk mengubah lokasi file log, ikuti tahapan dibawah ini.

    [root@PostgreSQL-50G ~]# vi /var/lib/pgsql/9.3/data/postgresql.conf 
    

    .
    .
    .
    #------------------------------------------------------------------------------
    # ERROR REPORTING AND LOGGING
    #------------------------------------------------------------------------------
    
    # - Where to Log -
    
    log_destination = 'stderr'              # Valid values are combinations of
                                            # stderr, csvlog, syslog, and eventlog,
                                            # depending on platform.  csvlog
                                            # requires logging_collector to be on.
    
    # This is used when logging to stderr:
    logging_collector = on                  # Enable capturing of stderr and csvlog
                                            # into log files. Required to be on for
                                            # csvlogs.
                                            # (change requires restart)
    
    # These are only used if logging_collector is on:
    #log_directory = 'pg_log'               # directory where log files are written,
    log_directory = '/var/log/postgresql'
                                            # can be absolute or relative to PGDATA
    log_filename = 'postgresql-%a.log'      # log file name pattern,
                                            # can include strftime() escapes
    #log_file_mode = 0600                   # creation mode for log files,
                                            # begin with 0 to use octal notation
    log_truncate_on_rotation = on           # If on, an existing log file with the
                                            # same name as the new log file will be
                                            # truncated rather than appended to.
                                            # But such truncation only occurs on
                                            # time-driven rotation, not on restarts
                                            # or size-driven rotation.  Default is
                                            # off, meaning append to existing files
                                            # in all cases.
    log_rotation_age = 1d                   # Automatic rotation of logfiles will
                                            # happen after that time.  0 disables.
    log_rotation_size = 0                   # Automatic rotation of logfiles will
    .
    .
    .
    

    [root@PostgreSQL-50G ~]# mkdir /var/log/postgresql
    [root@PostgreSQL-50G ~]# chown -R postgres:postgres /var/log/postgresql/
    [root@PostgreSQL-50G ~]# ls -l /var/log
    total 1016
    -rw-------. 1 root     root       6732 Sep  8 13:57 anaconda.ifcfg.log
    -rw-------. 1 root     root      18066 Sep  8 13:57 anaconda.log
    -rw-------. 1 root     root      23328 Sep  8 13:57 anaconda.program.log
    -rw-------. 1 root     root      92505 Sep  8 13:57 anaconda.storage.log
    -rw-------. 1 root     root      33206 Sep  8 13:57 anaconda.syslog
    -rw-------. 1 root     root       1829 Sep  8 13:57 anaconda.yum.log
    drwxr-x---. 2 root     root       4096 Mei 28 21:37 audit
    -rw-r--r--. 1 root     root       1434 Sep 13 10:52 boot.log
    -rw-------. 1 root     utmp          0 Sep 11 12:07 btmp
    -rw-------. 1 root     root      11358 Sep 13 12:01 cron
    -rw-r--r--. 1 root     root      14164 Sep 13 10:52 dmesg
    -rw-r--r--. 1 root     root      14322 Sep 12 17:14 dmesg.old
    -rw-r--r--. 1 root     root     330874 Sep 11 12:10 dracut.log
    drwx------. 2 root     root       4096 Sep 12 07:28 httpd
    -rw-r--r--. 1 root     root     146000 Sep 13 10:57 lastlog
    -rw-------. 1 root     root       4115 Sep 13 10:52 maillog
    -rw-------. 1 root     root     278922 Sep 13 10:52 messages
    -rwx------. 1 postgres postgres      0 Sep 11 12:19 pgsql
    drwxr-xr-x. 2 postgres postgres   4096 Sep 13 12:41 postgresql
    -rw-------. 1 root     root      21009 Sep 13 12:40 secure
    -rw-------. 1 root     root          0 Sep  8 13:55 spooler
    -rw-------. 1 root     root          0 Sep  8 13:55 tallylog
    -rw-rw-r--. 1 root     utmp      90624 Sep 13 10:57 wtmp
    -rw-------. 1 root     root       7763 Sep 12 07:15 yum.log
    
    [root@PostgreSQL-50G ~]# /etc/init.d/postgresql-9.3 restart
    Stopping postgresql-9.3 service:                           [  OK  ]
    Starting postgresql-9.3 service:                           [  OK  ]
    
    [root@PostgreSQL-50G ~]# ls -l /var/log/postgresql/
    total 4
    -rw-------. 1 postgres postgres 243 Sep 13 12:42 postgresql-Sat.log
    
    [root@PostgreSQL-50G ~]# tail -f /var/log/postgresql/postgresql-Sat.log 
    < 2014-09-13 12:42:10.451 WIB >LOG:  database system was shut down at 2014-09-13 12:40:55 WIB
    < 2014-09-13 12:42:10.459 WIB >LOG:  database system is ready to accept connections
    < 2014-09-13 12:42:10.461 WIB >LOG:  autovacuum launcher started
    < 2014-09-13 12:43:14.177 WIB >FATAL:  database "havizul" does not exist
    < 2014-09-13 12:44:46.233 WIB >FATAL:  database "havizul" does not exist
    < 2014-09-13 12:45:59.464 WIB >FATAL:  password authentication failed for user "user1"
    < 2014-09-13 12:45:59.464 WIB >DETAIL:  Connection matched pg_hba.conf line 94: "host    all             all             192.168.96.0/21         md5"
    < 2014-09-13 12:46:15.820 WIB >FATAL:  database "user1" does not exist
    ^C
    

    Konfigurasi PogreSQL 9.3 agar bisa di akses melalui jaringan

    Edit file "/var/lib/pgsql/9.3/data/pg_hba.conf".

    [root@PostgreSQL-50G ~]# vi /var/lib/pgsql/9.3/data/pg_hba.conf
    

    .
    .
    .
    .
    # TYPE  DATABASE        USER            ADDRESS                 METHOD
    
    # "local" is for Unix domain socket connections only
    local   all             all                                     peer
    # IPv4 local connections:
    host    all             all             127.0.0.1/32            ident
    host    all             all             192.168.96.0/21         trust
    host    all             all             172.16.16.96/27         trust 
    # IPv6 local connections:
    host    all             all             ::1/128                 ident
    # Allow replication connections from localhost, by a user with the
    # replication privilege.
    #local   replication     postgres                                peer
    #host    replication     postgres        127.0.0.1/32            ident
    #host    replication     postgres        ::1/128                 ident
    

    [root@PostgreSQL-50G ~]# /etc/init.d/postgresql-9.3 restart
    Stopping postgresql-9.3 service:                           [  OK  ]
    Starting postgresql-9.3 service:                           [  OK  ]
    

    Saya memperbolehkan semua host di dalam jaringan 192.168.96.0/21 dan 172.16.16.96/27 untuk mengakses PostgreSQL Server. Kemudian konfigurasi TCP/IP seperti di bawah ini.

    [root@PostgreSQL-50G ~]# vi /var/lib/pgsql/9.3/data/postgresql.conf
    

    .
    .
    .
    #TAMBAHAN: ALLOW ALL SRC-ADDRESS - END
    listen_addresses = '*'
    port = 5432
    #TAMBAHAN: ALLOW ALL SRC-ADDRESS - END
    .
    .
    .
    

    Untuk membuktikan bahwa postgresql sudah bisa diakses melalui jaringan, maka silahkan coba. Terlebih dahulu install postgresql client di host tersebut. Ketikkan perintah-perintah di bawah ini. Disini host yang digunakan adalah pc dengan OS Ubuntu Desktop 14.04.

    it@it-H55M-S2:~$ cat /etc/os-release 
    NAME="Ubuntu"
    VERSION="14.04, Trusty Tahr"
    ID=ubuntu
    ID_LIKE=debian
    PRETTY_NAME="Ubuntu 14.04 LTS"
    VERSION_ID="14.04"
    HOME_URL="http://www.ubuntu.com/"
    SUPPORT_URL="http://help.ubuntu.com/"
    BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
    
    it@it-H55M-S2:~$ ifconfig eth0
    eth0      Link encap:Ethernet  HWaddr 1c:6f:65:94:e5:fd  
              inet addr:192.168.100.16  Bcast:192.168.100.63  Mask:255.255.255.192
              inet6 addr: fe80::1e6f:65ff:fe94:e5fd/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:314834 errors:0 dropped:0 overruns:0 frame:0
              TX packets:316098 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:152066882 (152.0 MB)  TX bytes:40850565 (40.8 MB)
    
    it@it-H55M-S2:~$ sudo apt-get install postgresql-client-common postgresql-client-9.3 
    
    it@it-H55M-S2:~$ psql -h 172.16.16.125 -U postgres
    psql (9.3.5)
    Type "help" for help.
    
    postgres=# 
    

    Selamat anda telah terkoneksi ke server postgresql yang memiliki alamat ip 172.16.16.125.


    Menginstal phpPgAdmin
    phpPgAdmin adalah utility yang bisa digunakan untuk melakukan administrasi terhadap server PostgreSQL berbasiskan Web. phpPgAdmin hanya tersedia di Repository RPM PostgreSQL. Untuk menginstall phpPgAdmin, gunakan perintah seperti berikut ini.

    [root@PostgreSQL-50G ~]# yum install phpPgAdmin
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: kartolo.sby.datautama.net.id
     * extras: kartolo.sby.datautama.net.id
     * updates: kartolo.sby.datautama.net.id
    base                                                     | 3.7 kB     00:00     
    extras                                                   | 3.3 kB     00:00     
    pgdg93                                                   | 3.7 kB     00:00     
    updates                                                  | 3.4 kB     00:00     
    updates/primary_db                                       | 5.3 MB     00:38     
    Setting up Install Process
    Resolving Dependencies
    --> Running transaction check
    ---> Package phpPgAdmin.noarch 0:5.1-1.rhel6 will be installed
    --> Processing Dependency: php-pgsql >= 4.2 for package: phpPgAdmin-5.1-1.rhel6.noarch
    --> Processing Dependency: php >= 4.2 for package: phpPgAdmin-5.1-1.rhel6.noarch
    --> Processing Dependency: httpd for package: phpPgAdmin-5.1-1.rhel6.noarch
    --> Running transaction check
    ---> Package httpd.x86_64 0:2.2.15-31.el6.centos will be installed
    --> Processing Dependency: httpd-tools = 2.2.15-31.el6.centos for package: httpd-2.2.15-31.el6.centos.x86_64
    --> Processing Dependency: apr-util-ldap for package: httpd-2.2.15-31.el6.centos.x86_64
    --> Processing Dependency: /etc/mime.types for package: httpd-2.2.15-31.el6.centos.x86_64
    --> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.2.15-31.el6.centos.x86_64
    --> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.2.15-31.el6.centos.x86_64
    ---> Package php.x86_64 0:5.3.3-27.el6_5.1 will be installed
    --> Processing Dependency: php-common(x86-64) = 5.3.3-27.el6_5.1 for package: php-5.3.3-27.el6_5.1.x86_64
    --> Processing Dependency: php-cli(x86-64) = 5.3.3-27.el6_5.1 for package: php-5.3.3-27.el6_5.1.x86_64
    ---> Package php-pgsql.x86_64 0:5.3.3-27.el6_5.1 will be installed
    --> Processing Dependency: php-pdo(x86-64) for package: php-pgsql-5.3.3-27.el6_5.1.x86_64
    --> Running transaction check
    ---> Package apr.x86_64 0:1.3.9-5.el6_2 will be installed
    ---> Package apr-util.x86_64 0:1.3.9-3.el6_0.1 will be installed
    ---> Package apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 will be installed
    ---> Package httpd-tools.x86_64 0:2.2.15-31.el6.centos will be installed
    ---> Package mailcap.noarch 0:2.1.31-2.el6 will be installed
    ---> Package php-cli.x86_64 0:5.3.3-27.el6_5.1 will be installed
    ---> Package php-common.x86_64 0:5.3.3-27.el6_5.1 will be installed
    ---> Package php-pdo.x86_64 0:5.3.3-27.el6_5.1 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ================================================================================
     Package            Arch        Version                      Repository    Size
    ================================================================================
    Installing:
     phpPgAdmin         noarch      5.1-1.rhel6                  pgdg93       675 k
    Installing for dependencies:
     apr                x86_64      1.3.9-5.el6_2                base         123 k
     apr-util           x86_64      1.3.9-3.el6_0.1              base          87 k
     apr-util-ldap      x86_64      1.3.9-3.el6_0.1              base          15 k
     httpd              x86_64      2.2.15-31.el6.centos         updates      824 k
     httpd-tools        x86_64      2.2.15-31.el6.centos         updates       73 k
     mailcap            noarch      2.1.31-2.el6                 base          27 k
     php                x86_64      5.3.3-27.el6_5.1             updates      1.1 M
     php-cli            x86_64      5.3.3-27.el6_5.1             updates      2.2 M
     php-common         x86_64      5.3.3-27.el6_5.1             updates      526 k
     php-pdo            x86_64      5.3.3-27.el6_5.1             updates       76 k
     php-pgsql          x86_64      5.3.3-27.el6_5.1             updates       71 k
    
    Transaction Summary
    ================================================================================
    Install      12 Package(s)
    
    Total download size: 5.7 M
    Installed size: 20 M
    Is this ok [y/N]: y    
    Downloading Packages:
    (1/12): apr-1.3.9-5.el6_2.x86_64.rpm                     | 123 kB     00:00     
    (2/12): apr-util-1.3.9-3.el6_0.1.x86_64.rpm              |  87 kB     00:00     
    (3/12): apr-util-ldap-1.3.9-3.el6_0.1.x86_64.rpm         |  15 kB     00:00     
    (4/12): httpd-2.2.15-31.el6.centos.x86_64.rpm            | 824 kB     00:05     
    (5/12): httpd-tools-2.2.15-31.el6.centos.x86_64.rpm      |  73 kB     00:00     
    (6/12): mailcap-2.1.31-2.el6.noarch.rpm                  |  27 kB     00:00     
    (7/12): php-5.3.3-27.el6_5.1.x86_64.rpm                  | 1.1 MB     00:08     
    (8/12): php-cli-5.3.3-27.el6_5.1.x86_64.rpm              | 2.2 MB     00:15     
    (9/12): php-common-5.3.3-27.el6_5.1.x86_64.rpm           | 526 kB     00:03     
    (10/12): php-pdo-5.3.3-27.el6_5.1.x86_64.rpm             |  76 kB     00:00     
    (11/12): php-pgsql-5.3.3-27.el6_5.1.x86_64.rpm           |  71 kB     00:00     
    (12/12): phpPgAdmin-5.1-1.rhel6.noarch.rpm               | 675 kB     00:05     
    --------------------------------------------------------------------------------
    Total                                           137 kB/s | 5.7 MB     00:42     
    Running rpm_check_debug
    Running Transaction Test
    Transaction Test Succeeded
    Running Transaction
      Installing : php-common-5.3.3-27.el6_5.1.x86_64                          1/12 
      Installing : apr-1.3.9-5.el6_2.x86_64                                    2/12 
      Installing : apr-util-1.3.9-3.el6_0.1.x86_64                             3/12 
      Installing : apr-util-ldap-1.3.9-3.el6_0.1.x86_64                        4/12 
      Installing : httpd-tools-2.2.15-31.el6.centos.x86_64                     5/12 
      Installing : php-pdo-5.3.3-27.el6_5.1.x86_64                             6/12 
      Installing : php-pgsql-5.3.3-27.el6_5.1.x86_64                           7/12 
      Installing : php-cli-5.3.3-27.el6_5.1.x86_64                             8/12 
      Installing : mailcap-2.1.31-2.el6.noarch                                 9/12 
      Installing : httpd-2.2.15-31.el6.centos.x86_64                          10/12 
      Installing : php-5.3.3-27.el6_5.1.x86_64                                11/12 
      Installing : phpPgAdmin-5.1-1.rhel6.noarch                              12/12 
    Non-fatal POSTIN scriptlet failure in rpm package phpPgAdmin-5.1-1.rhel6.noarch
    warning: %post(phpPgAdmin-5.1-1.rhel6.noarch) scriptlet failed, exit status 7
      Verifying  : php-pdo-5.3.3-27.el6_5.1.x86_64                             1/12 
      Verifying  : php-cli-5.3.3-27.el6_5.1.x86_64                             2/12 
      Verifying  : php-pgsql-5.3.3-27.el6_5.1.x86_64                           3/12 
      Verifying  : httpd-2.2.15-31.el6.centos.x86_64                           4/12 
      Verifying  : php-5.3.3-27.el6_5.1.x86_64                                 5/12 
      Verifying  : apr-util-ldap-1.3.9-3.el6_0.1.x86_64                        6/12 
      Verifying  : phpPgAdmin-5.1-1.rhel6.noarch                               7/12 
      Verifying  : httpd-tools-2.2.15-31.el6.centos.x86_64                     8/12 
      Verifying  : mailcap-2.1.31-2.el6.noarch                                 9/12 
      Verifying  : apr-1.3.9-5.el6_2.x86_64                                   10/12 
      Verifying  : php-common-5.3.3-27.el6_5.1.x86_64                         11/12 
      Verifying  : apr-util-1.3.9-3.el6_0.1.x86_64                            12/12 
    
    Installed:
      phpPgAdmin.noarch 0:5.1-1.rhel6                                               
    
    Dependency Installed:
      apr.x86_64 0:1.3.9-5.el6_2                apr-util.x86_64 0:1.3.9-3.el6_0.1  
      apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1    httpd.x86_64 0:2.2.15-31.el6.centos
      httpd-tools.x86_64 0:2.2.15-31.el6.centos mailcap.noarch 0:2.1.31-2.el6      
      php.x86_64 0:5.3.3-27.el6_5.1             php-cli.x86_64 0:5.3.3-27.el6_5.1  
      php-common.x86_64 0:5.3.3-27.el6_5.1      php-pdo.x86_64 0:5.3.3-27.el6_5.1  
      php-pgsql.x86_64 0:5.3.3-27.el6_5.1      
    
    Complete!
    

    Lihatlah, dengan menginstal phpPgAdmin, paket httpd juga secara otomatis diinstall. Setelah selesai menginstall phpPgAdmin, kita dapat secara langsung mengaksesnya melalui alamat : http://localhost/phpPgAdmin, namun hanya bisa dilakukan secara local. Agar dapat mengakses phpPgAdmin secara remote, maka lakukan konfigurasi pada file "/etc/httpd/conf.d/phpPgAdmin.conf". Ikuti langkah-langkah berikut ini untuk mengkonfigurasi httpd.

    [root@PostgreSQL-50G ~]# vi /etc/httpd/conf.d/phpPgAdmin.conf
    

    #
    # This configuration file maps the phpPgAdmin directory into the URL space. 
    # By default this application is only accessible from the local host.
    #
    
    Alias /phpPgAdmin /usr/share/phpPgAdmin
    
    <Location /phpPgAdmin>
        Order deny,allow
    #   Deny from all
        allow from all
        Allow from 127.0.0.1
        Allow from ::1
        # Allow from .example.com
    </Location>
    

    [root@PostgreSQL-50G ~]# service httpd start
    Starting httpd: httpd: apr_sockaddr_info_get() failed for PostgreSQL-50G
    httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
                                                               [  OK  ]
    [root@PostgreSQL-50G ~]# chkconfig httpd on
    

    Kemudian ubah konfigurasi phpPgAdmin seperti berikut ini.

    [root@PostgreSQL-50G ~]# vi /etc/phpPgAdmin/config.inc.php
    

    .
    .
            // Hostname or IP address for server.  Use '' for UNIX domain socket.
            // use 'localhost' for TCP/IP connection on this computer
            //$conf['servers'][0]['host'] = '';
            $conf['servers'][0]['host'] = 'localhost';
    .
    .
    .
            // If extra login security is true, then logins via phpPgAdmin with no
            // password or certain usernames (pgsql, postgres, root, administrator)
            // will be denied. Only set this false once you have read the FAQ and
            // understand how to change PostgreSQL's pg_hba.conf to enable
            // passworded local connections.
            //$conf['extra_login_security'] = true;
            $conf['extra_login_security'] = false;
    
            // Only show owned databases?
            // Note: This will simply hide other databases in the list - this does
            // not in any way prevent your users from seeing other database by
            // other means. (e.g. Run 'SELECT * FROM pg_database' in the SQL area.)
            //$conf['owned_only'] = false;
            $conf['owned_only'] = true;
    .
    .
    .
    

    [root@PostgreSQL-50G ~]# /etc/init.d/postgresql-9.3 restart
    Stopping postgresql-9.3 service:                           [  OK  ]
    Starting postgresql-9.3 service:                           [  OK  ]
    [root@PostgreSQL-50G ~]# service httpd restart
    Stopping httpd:                                            [  OK  ]
    Starting httpd: httpd: apr_sockaddr_info_get() failed for PostgreSQL-50G
    httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
                                                               [  OK  ]
    

    Sekarang cobalah buka browser anda, disini saya mencoba mengakses phpPgAdmin masih melalui host Ubuntu Desktop yang memiliki ip address 192.168.16.100.



Sekian dan selamat mencoba.









JANGAN LUPA DI-SUBSCRIBE CHANNEL YOUTUBE-NYA YA KAWAN !