PostgreSQL is available in all Ubuntu versions by default. However, Ubuntu"snapshots" a specific version of PostgreSQL that is then supported throughoutthe lifetime of that Ubuntu version.The PostgreSQL project maintains anApt repository with all supportedof PostgreSQL available.
Ubuntu includes PostgreSQL by default. To install PostgreSQL on Ubuntu,use theapt
(or other apt-driving) command:
apt install postgresql
If the version included in your version of Ubuntu is not the one you want,you can use thePostgreSQL Apt Repository. This repository will integratewith your normal systems and patch management, and provide automaticupdates for all supported versions of PostgreSQL throughout the supportlifetime of PostgreSQL.
The PostgreSQL Apt repository supports the current versions of Ubuntu:
on the following architectures:
Automated repository configuration:
sudo apt install -y postgresql-commonsudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
To manually configure the Apt repository, follow these steps:
# Import the repository signing key:sudo apt install curl ca-certificatessudo install -d /usr/share/postgresql-common/pgdgsudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc# Create the repository configuration file:. /etc/os-releasesudo sh -c "echo 'deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $VERSION_CODENAME-pgdg main' > /etc/apt/sources.list.d/pgdg.list"# Update the package lists:sudo apt update
sudo apt install postgresql-18
For more information about the apt repository, including answers to frequentquestions, please see thePostgreSQL Apt Repository wiki page.
The repository contains many different packages including third partyaddons. The most common and important packages are (substitute theversion number as required):
postgresql-client-18 | client libraries and client binaries |
---|---|
postgresql-18 | core database server |
postgresql-doc-18 | documentation |
libpq-dev | libraries and headers for C language frontend development |
postgresql-server-dev-18 | libraries and headers for C language backend development |