Installing on Ubuntu / Debian
-
The PostgreSQL project documents the current Debian and Ubuntu package setup on the Debian download page and Ubuntu download page. Follow those instructions for the PostgreSQL Apt Repository. The automated repository setup is:
sudo apt install -y postgresql-common sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -
For source builds and contributor test environments, see the Ubuntu development environment guide.
After configuring the PostgreSQL Apt Repository, replace 18 below with the
PostgreSQL major you want to run:
sudo apt install postgresql-18 postgresql-18-postgis-3
Install the PostGIS command-line tools, such as shp2pgsql and raster2pgsql,
with:
sudo apt install postgis
Debian-style PostgreSQL packages can install several PostgreSQL majors side by side. Check the active clusters and ports with:
pg_lsclusters
Create a user database before enabling extensions. Do not install PostGIS in the
default postgres maintenance database:
CREATE DATABASE gisdb;
\connect gisdb
CREATE EXTENSION postgis;
SELECT postgis_full_version();
Enable optional extensions only when you need them:
CREATE EXTENSION postgis_raster;
CREATE EXTENSION postgis_topology;
CREATE EXTENSION postgis_sfcgal;
Packages for related projects such as pgRouting follow the same PostgreSQL-major
pattern, for example postgresql-18-pgrouting.