How to Install PostGIS PostgreSQL database extender on CentOS 8

PostGIS is a free and open-source database extender for the PostgreSQL Database Management System. It helps you to add some extra functions such as, area, union, intersection, distance, data types, and allow location queries to be run in SQL. With PostGIS, you can store the polygon and point types of the data in the PostgreSQL database.

In this tutorial, we will show you how to install PostGIS with PostgreSQL on CentOS 8.


  • A server running CentOS 8.
  • A root password is configured on your server.

Getting Started

Before starting, you will need to install PostGIS and EPEL repo to your system. You can install both by running the following command:

dnf -y install
dnf -y install

Next, enable the Powertool repo and disable the default PostgreSQL repo with the following command:

dnf config-manager --set-enabled PowerTools
dnf -qy module disable postgresql

Once you are finished, you can proceed to the next step.

Install PostGIS

Now, you can install the PostGIS by running the following command:

dnf install postgis25_12

Once the installation has been completed, you can verify the PostGIS package with the following command:

rpm -qi postgis25_12

You should get the following output:

Name        : postgis25_12
Version     : 2.5.5
Release     : 2.rhel8
Architecture: x86_64
Install Date: Monday 01 February 2021 11:59:37 PM EST
Group       : Unspecified
Size        : 29832534
License     : GPLv2+
Signature   : DSA/SHA1, Tuesday 10 November 2020 01:36:47 PM EST, Key ID 1f16d2e1442df0f8
Source RPM  : postgis25_12-2.5.5-2.rhel8.src.rpm
Build Date  : Tuesday 10 November 2020 01:30:09 PM EST
Build Host  : koji-rhel8-x86-64-pgbuild
Relocations : (not relocatable)
Vendor      : PostgreSQL Global Development Group
URL         :
Summary     : Geographic Information Systems Extensions to PostgreSQL
Description :
PostGIS adds support for geographic objects to the PostgreSQL object-relational
database. In effect, PostGIS "spatially enables" the PostgreSQL server,
allowing it to be used as a backend spatial database for geographic information
systems (GIS), much like ESRI's SDE or Oracle's Spatial extension. PostGIS
follows the OpenGIS "Simple Features Specification for SQL" and has been
certified as compliant with the "Types and Functions" profile.

Next, initialize the PostgreSQL database with the following command:

/usr/pgsql-12/bin/postgresql-12-setup initdb

Next, start the PostgreSQL service and enable it to start at system reboot with the following command:

systemctl start postgresql-12.service
systemctl enable postgresql-12.service

Create an Extension

At this point, PostgreSQL and PostGIS have been installed. Now, you will need to create an extension for PostGIS.

First, login to Postgres user with the following command:

su - postgres

Next, create a postgres user and database with the following command:

createuser test_usr
createdb test_postgis -O test_usr

Next, connect to the database with the following command:

psql -d test_postgis

You should see the following output:

psql (12.5)
Type "help" for help.

Next, create a PostGIS extension with the following command:


Next, you can verify the PostGIS version using the following command:

select PostGIS_Full_Version();

You should see the PostGIS version in the following output:

 POSTGIS="2.5.5" [EXTENSION] PGSQL="120" GEOS="3.8.1-CAPI-1.13.3" PROJ="Rel. 7.2.1, January 1st, 2021" GDAL="GDAL 3.2.1, released 2020/12/29" L
(1 row)

Next, exit from the Postgres shell with the following command;



In the above guide, you learned how to install PostGIS with PostgreSQL on CentOS 8. You can now use PostGIS to add geometry to your database.

Share this page:

1 Comment(s)