PostGIS is a special spatial extension for PostgreSQL. With this extension, we can store spatial and geometry information to a table or database. It regarded as a powerful way to store our GIS datasets.

Here we will be learning how to install PostGIS, PostgreSQl and enabling the PostGIS extension on our Ubuntu 18.04. PostGIS extension is not enabled by default on standard PostgreSQL installation hence we need to enable it on each database that we intend to use.

For most parts of this step-by-step tutorial we will be using the terminal command line.

Installing PostgreSQL

Download PostgreSQL package for Linux by EnterpriseDB

Make the package executable by entering the following commands

sudo chmod +x postgresql-9.6.9-1-linux-x64.run

Run the installer

sudo ./postgresql-9.6.9-1-linux-x64.run

The GUI installation wizard will open up

Specify the installation directory. I would recommend leaving the default location, but you can change.

Also specify the data directory

Provide a password for the Postgres root user

On the next screen set to [Default locale] and wait until the installation is completed.

When the installation is complete then click Finish. You can check the Stack Builder option box that shows after the installation has been completed in order to add some functionality to your new PostgreSQL

Installing PostGIS

Now that we have installed PostgreSQL let’s continue to install PostGIS. Again we will be using the command lines for our installation.

sudo apt install postgis

Your terminal should display an output more like the one below:

Now install PgAdmin4. Tjis is a web based tool to manage our PostgreSQL server. Use the command line below in the terminal.

sudo apt install pgadmin4 

After this, the PgAdmin4 icon should appear in your applications list. Open it to start configuration of the server.

If you face any challenges feel free to come through and discuss at the forum so that everyone can also benefit.