Install PostgreSQL 9.5 on Debian/Ubuntu servers
Introduction
PostgreSQL 9.5 was released on 01/07/2016. More information about the release is available on the official PostgreSQL documentation.
Install PostgreSQL 9.5 step by step
Install wget & ca-certificates and trust PostgreSQL's key
apt-get update
apt-get -y install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
Add the PostgreSQL repository to your sources
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list
Install PostgreSQL 9.5
apt-get update
apt-get -y install postgresql-9.5
Connection to PostgreSQL
su postgres
psql