On most GNU+Linux operating systems, PostgreSQL can easily be installed using the operating system package manager.
Respositories can be found here: https://yum.postgresql.org/repopackages.php
Download the repository to local machine with the command
yum -y install https://download.postgresql.org/pub/repos/yum/X.X/redhat/rhel-7-x86_64/pgdg-redhatXX-X.X-X.noarch.rpm
View available packages:
yum list available | grep postgres*
Neccesary packages are: postgresqlXX postgresqlXX-server postgresqlXX-libs postgresqlXX-contrib
These are installed with the following command: yum -y install postgresqlXX postgresqlXX-server postgresqlXX-libs postgresqlXX-contrib
Once installed you will need to start the database service as the service owner (Default is postgres). This is done with the pg_ctl command.
sudo -su postgres
./usr/pgsql-X.X/bin/pg_ctl -D /var/lib/pgsql/X.X/data start
To access the DB in CLI enter psql
On Debian and derived operating systems, type:
sudo apt-get install postgresql
This will install the PostgreSQL server package, at the default version offered by the operating system's package repositories.
If the version that's installed by default is not the one that you want, you can use the package manager to search for specific versions which may simultaneously be offered.
You can also use the Yum repository provided by the PostgreSQL project (known as PGDG) to get a different version. This may allow versions not yet offered by operating system package repositories.