- Currently Ubuntu ships with Postgres 12. At time of writing, Postgres 15 is available.
- If you follow the Ubuntu instructions, APT will log a message that "apt-key is deprecated" every time you check for updates.
This is how to do it right.
Based on information here:
# Add the Postgres keyring USING A SEPARATE SIGNING KEY FILE
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/postgres-archive-keyring.gpg] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
# Download Postgre' signing key INTO ITS OWN FILE
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc \
| gpg --dearmor \
| sudo tee /usr/share/keyrings/postgres-archive-keyring.gpg
# Update the package lists:
sudo apt-get update
# Install the latest version of PostgreSQL.
# If you want a specific version, use 'postgresql-12' or similar instead of 'postgresql':
sudo apt-get -y install postgresql