Saturday, June 14, 2025
Sponsored Ad
Google search engine
HomeData Modelling & AIHow to Install PostGIS on CentOS 7 / RHEL 7

How to Install PostGIS on CentOS 7 / RHEL 7

How can I install PostGIS on CentOS 7?. This guide will walk you through the steps of installing PostGIS on CentOS 7 / RHEL 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 using PostGIS features. Install it on CentOS 7 / RHEL 7 using our guide below.

Step 2: Add EPEL repository to CentOS 7 / RHEL 7

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

sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

Step 3: Install PostGIS on CentOS 7 / RHEL 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.

sudo yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

PostGIS on PostgreSQL 12:

sudo yum install postgis33_15

PostGIS on PostgreSQL 14:

sudo yum install postgis33_14

PostGIS on PostgreSQL 13:

sudo yum install postgis33_13

PostGIS on PostgreSQL 12:

sudo yum install postgis33_12

PostGIS on PostgreSQL 11

sudo yum install postgis25_11

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 (13.16)
 Type "help" for help.

4.Enable the PostGIS extension on the database:

test_db=# CREATE EXTENSION postgis;
 CREATE EXTENSION

5. Verify

test_db=# SELECT PostGIS_version();
             postgis_version            
 2.5 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
 (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

How to Install Latest Redis on CentOS 7

Installing MongoDB 4.4 on CentOS 7 / Fedora

RELATED ARTICLES

Most Popular

Dominic
31275 POSTS0 COMMENTS
Milvus
17 POSTS0 COMMENTS
Nango Kala
5310 POSTS0 COMMENTS
Nicole Veronica
8112 POSTS0 COMMENTS
Nokonwaba Nkukhwana
8147 POSTS0 COMMENTS
Shaida Kate Naidoo
5604 POSTS0 COMMENTS
Ted Musemwa
5740 POSTS0 COMMENTS
Thapelo Manthata
5226 POSTS0 COMMENTS
Umr Jansen
5363 POSTS0 COMMENTS