1. First, we’ll obtain the authentication keys needed to validate packages from the PostgreSQL repo.
$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
2. As a best practice, we will update our server before installing PostgreSQL.
$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -sc)-pgdg main" > /etc/apt/sources.list.d/PostgreSQL.list'
3. After the update is complete, we’ll run the following command to install PostgreSQL
$ sudo apt-get -y update
4. After the update is complete, we’ll run the following command to install PostgreSQL
$ sudo apt-get install postgresql-10