sudo rpm -Uvh
sudo yum update
sudo yum install postgresql94-server postgresql94-contrib
sudo yum install postgresql postgresql-contrib postgresql-client
sudo yum install postgresql-server-dev-9.4 (for server)
sudo yum install libpq-dev (for client)
sudo yum install postgresql-devel
sudo service postgresql-9.4 initdb
sudo service postgresql-9.4 start
sudo chkconfig postgresql-9.4 on

sudo nano /etc/sysconfig/iptables

Add the following line:

-A INPUT -m state –state NEW -m tcp -p tcp –dport 5432 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT

sudo service iptables restart

sudo su - postgres
["\q" or "quit" to quit but don't now]
\password postgres
postgres=# CREATE EXTENSION adminpack;
createuser USER
createdb DBNAME
alter user USER with encrypted password 'PASSWORD';
grant all privileges on database DBNAME to USER;

Configure PostgreSQL-MD5 Authentication

sudo nano /var/lib/pgsql/9.4/data/pg_hba.conf

Add or Modify the lines as shown below

# "local" is for Unix domain socket connections only
 local all all md5
 # IPv4 local connections:
 host all all md5
 host all all md5
 # IPv6 local connections:
 host all all ::1/128 md5
sudo service postgresql-9.4 restart

Configure PostgreSQL-Configure TCP/IP

sudo nano /var/lib/pgsql/9.4/data/postgresql.conf

Find the lines (Uncomment):

 #listen_addresses = 'localhost'
 #port = 5432


Change to:

 listen_addresses = '*'
 port = 5432

sudo /etc/init.d/postgresql-9.4 restart