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.

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

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

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

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 https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

sudo yum install postgis25_12

PostGIS on PostgreSQL 11

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

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.5

Release : 5.rhel7

Architecture: x86_64

Install Date: Fri May 20 13:08:44 2022

Group : Unspecified

Size : 29719583

License : GPLv2+

Signature : DSA/SHA1, Wed Jul 14 18:56:42 2021, Key ID 1f16d2e1442df0f8

Source RPM : postgis25_11-2.5.5-5.rhel7.src.rpm

Build Date : Wed Jul 14 18:55:52 2021

Build Host : koji-centos7-x86-64-pgbuild

Relocations : (not relocatable)

Vendor : PostgreSQL Global Development Group

URL : http://www.postgis.net/

Summary : Geographic Information Systems Extensions to PostgreSQL

....

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.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.

https://www.computingpost.com/how-to-install-postgis-on-centos-7-rhel-7/?feed_id=1623&_unique_id=632d4b8134df4

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
ComputingPost

ComputingPost — Linux Howtos, Tutorials, Guides, News, Tips and Tricks.