How can I install PostGIS on CentOS 7?. This guide will walk you through the steps of installing PostGIS on CentOS 7. PostGIS is a PostgreSQL database extension which allows GIS (Geographic Information Systems) objects to be stored in the database.

install postgis centos7

PostGIS includes support for GiST-based R-Tree spatial indexes and functions for analysis and processing of GIS objects. It is an open source software licensed under a Creative Commons Attribution-Share Alike 3.0 License.

For CentOS 8, use: How To Install PostGIS on CentOS 8

Step 1: Install PostgreSQL Database server

PostgreSQL is a dependency for usinf PostGIS features. Install it on CentOS 7 using our guide below.

How to install PostgreSQL 11 on CentOS 7

How to install PostgreSQL 12 on CentOS 7

Step 2: Add EPEL repository to CentOS 7

A number of dependencies are on the EPEL repository. Run the following command to install epel repository in your CentOS 7 machine.

sudo yum -y install epel-release

Step 3: Install PostGIS on CentOS 7

After the installation of PostgreSQL and adding EPEL repository, proceed to install PostGIS from the PostgreSQL added. The repository was added using command like below.

PostGIS on PostgreSQL 12:

sudo yum -y install
sudo yum install postgis25_12

PostGIS on PostgreSQL 11

sudo yum -y install
sudo yum install postgis25_11

Check PostGIS v2.5 version for your PostgreSQL release. The version installed can be checked with:

$ rpm -qi postgis25_11
Name : postgis25_11
Version : 2.5.1
Release : 4.rhel7
Architecture: x86_64
Install Date: Wed 20 Feb 2019 10:37:35 PM CET
Group : Applications/Databases
Size : 32649231
License : GPLv2+
Signature : DSA/SHA1, Wed 02 Jan 2019 12:45:12 PM CET, Key ID 1f16d2e1442df0f8
Source RPM : postgis25_11-2.5.1-4.rhel7.src.rpm
Build Date : Wed 02 Jan 2019 12:44:54 PM CET
Build Host : koji-centos7-x86-64-pgbuild
Relocations : (not relocatable)
Vendor : PostgreSQL Global Development Group
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.

Step 4: Enable PostGIS Spatial features

You need to activate PostGIS features on a database before you can store spacial data. The example below will show you how to create a database and activate the Spacial features.

1.Switch to postgres user.

sudo -i -u postgres

2.Create test user/database.

-bash-4.2$ createuser test_user
-bash-4.2$ createdb test_db -O test_user

3.Connect to the test database:

-bash-4.2$ psql -d test_db
psql (11.2)
Type "help" for help.

4.Enable the PostGIS extension on the database:

test_db=# CREATE EXTENSION postgis;

5. Verify

test_db=# SELECT PostGIS_version();
(1 row)
test_db=# \q

Refer to Official PostGIS Documentation for a usage guide and advanced configurations.

Related Article:

Install pgAdmin 4 on CentOS 7 / Fedora 29 / Fedora 28

How to Install Latest Redis on CentOS 7

Installing MongoDB 4.0 on CentOS 7 / Fedora 29 / Fedora 28

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


Please enter your comment!
Please enter your name here