Install PostgreSQL 13 on CentOS 8

This post will cover installing PostgreSQL 13 on CentOS 8.

We’ll be using a bash script below, which is commented so you can see the steps.

We’ll install PostgreSQL using the PostgreSQL repository, configure the pg_hba.conf file to secure the instance, and update the postgresql.conf file to allow remote connections and enable SSL.

We will also create a self-signed SSL certificate for the cluster.

As root, you can save the above script as postgresql-13-centos-8.sh or, simpler still, use wget to grab scipt from Github:

As root, make the script executable:

Run the script:

Upon completion, the postgres and SSL password will be displayed as below:

The random passwords will also be saved as auth.txt in the root directory.

Tes your installation with su – postgres and then enter the password to start psql:

Looking at the files under /var/lib/pgsql/data, our pg_hba.conf looks like below:

Our postgresql.conf has also been updated both to allow connections as well as enable SSL:

 

 

 

Install PostGIS 3.x on CentOS 8

This post will cover install PostGIS 3.x on CentOS 8.

If you do not already have PostgreSQL 12 installed, do so here

PostGIS 3.x requires additional packages not available in the PostgreSQL repository.

Install the Epel repository for these dependencies:

With Epel installed, we can now use Yum to install the PostGIS 3.x packages from the PostgreSQL Repository:

Once completed, su to postgres and connect to the target database where you wish to enable PostGIS.

Below, we are using database ‘demo’:

Install the PostGIS extension using CREATE EXTENSION:

Check the PostGIS version installed:

Lets test out our extension using a basic example from https://postgis.net/docs/using_postgis_dbmanagement.html

Create a table with a GEOGRAPHY column:

Insert some data:

Select the name column values:

And run a Spatial Query:

Learn more at https://postgis.net/