Install PostGIS

For Ubuntu 22.04 you can simply install PostGIS with:

$ sudo apt install postgis

Then you can activate PostGIS.

  1. Switch to the PostgreSQL user:

    $ sudo -i -u postgres
    
  2. Create test user and database:

    $ createuser postgis
    $ createdb postgis_db -O postgis
    
  3. Establish a connection to the database:

    $ psql -d postgis_db
    psql (14.5 (Ubuntu 14.5-0ubuntu0.22.04.1))
     Type "help" for help.
    
  4. Activate the PostGIS extension in the database:

    ppostgis_db = # CREATE EXTENSION postgis;
    CREATE EXTENSION
    
  5. Check that PostGIS is working:

    postgis_db=# SELECT PostGIS_version();
                postgis_version
    ---------------------------------------
     3.2 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
    (1 row)