CentOS 6

1. Install PostgreSQL repository and the PostgreSQL server by running the following:
  1. sudo yum install https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-6-x86_64/pgdg-centos95-9.5-2.noarch.rpm
  2. sudo yum install postgresql95-serve

2. Create the PostgreSQL database cluster.
  1. sduo service postgresql-9.5 initdb

3. Enable automatic PostgreSQL server startup.
  1. sudo chkconfig postgresql-9.5 on

4. Start the PostgreSQL server.
  1. sudo service postgresql-9.5 start

CentOS 7

1. Install PostgreSQL repository and the PostgreSQL server by running the following:
  1. sudo yum install https://download.postgresql.org/pub/repos/yum/9.5 /redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm
  2. sudo yum install postgresql95-serve

2. Create the PostgreSQL database cluster.
  1. sudo /usr/pgsql-9.5/bin/postgresql95-setup initdb

3. Enable automatic PostgreSQL server startup.
  1. sudo systemctl enable postgresql-9.5

4. Start the PostgreSQL server.
  1. sudo systemctl start postgresql-9.5

Configurations for CentOS

When installing in CentOs env. you will also need to make the following configurations.

1. Change authentication to md5.
  1. sudo vi /var/lib/pgsql/9.5/data/pg_hba.conf

2. Change METHOD to md5.
  1. # IPv4 local connections:
  2. host all all 127.0.0.1/32 md5
  3. # IPv6 local connections:
  4. host all all ::1/128 md5

3. Restart PostgreSQL