References: Linux downloads (Debian)
Automated Repository Configuration
sudo apt install -y postgresql-common
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
Manual Repository Configuration
Import the repository key:
sudo apt install curl ca-certificates
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
Create /etc/apt/sources.list.d/pgdg.sources. The distributions are called codename-pgdg. In the example, replace trixie with the actual distribution you are using. File contents:
Types: deb deb-src
URIs: https://apt.postgresql.org/pub/repos/apt
Suites: trixie-pgdg
Architectures: amd64
Components: main
Signed-By: /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc
Install PostgreSQL: (replace "18" by the version you want)
sudo apt update
sudo apt install postgresql-18