How to install PostGIS in RHEL

In this article, we will see How to install PostGIS in RHEL.

What is Postgis?

PostGIS is a spatial database extender for PostgreSQL object-relational database. It adds support for geographic objects allowing location queries to be run in SQL. postgis is just extension to existing database. That also we have to add as shown below.

Prerequisites to install postgis extension on Linux:

1. PostgreSQL must be installed.
2. Internet connection.
3. Sudo or root privileges.

How to install PostGIS in RHEL

1. Lets verify Postgis is installed or not using below command:

SELECT e.extname AS "Name", e.extversion AS "Version", n.nspname AS "Schema", c.description AS "Description" FROM pg_catalog.pg_extension e LEFT JOIN pg_catalog.pg_namespace n ON n.oid = e.extnamespace LEFT JOIN pg_catalog.pg_description c ON c.objoid = e.oid AND c.classoid = 'pg_catalog.pg_extension'::pg_catalog.regclass ORDER BY 1;

or Simply run \dx meta command:

How to install PostGIS in RHEL

2. Install Postggis using below command:

dnf -y install postgis33_15

Where 33 is the version of postgis and 15 is the version of PostgreSQL.

3. Now, restart postgresql server

sudo systemctl restart postgresql-15

4. Now, connect to PostgreSQL database and create postgis extension.

CREATE EXTENSION postgis;