Step-by-step installation of installation of PostgreSQL 12.3 on CentOS 8.1 from source

In this post we have explained how to  (step-by-step) install PostgreSQL 12.3 on CentOS 8.1. Please don’t use this blog post for installation and configuration of PostgreSQL 12.3 from source in production, We have written this post only for learning purpose and definitely not a recommendation for PostgreSQL deployment. This installation was done from PostgreSQL 12.3 source file (Postgresql-12.3.tar.bz2). You can follow the same steps for PostgreSQL 12.3 installation on other versions of CentOS and “Red Hat Linux”, The following steps remain same for other PostgreSQL versions also. You can always configure custom values for OS user, group, installation directories, port etc.

Step-by-step installation of PostgreSQL 12.3 on CentOS 8.1

Step 1 

Confirm the CentOS Linux is configured accordingly for PostgreSQL installation and configuration.  Connect using PostgreSQL administration user

Step 2

You can create folders for PostgreSQL binaries, data, backup files etc.

  • binaries — /databases/postgres/postgres_binaries
  • data — /databases/postgres/postgres_data
  • logs — /databases/postgres/postgres_logs
  • backups — /databases/postgres/postgres_backup

Step 3

Confirm the owner of source tar file is PostgreSQL administration user and also grant 775 permission to the source tar file:

Step 4 

Create a new folder postgresql-12.3-installers to retain PostgreSQL installers:

Step 5 

Extract the source tar file:

Step 6 

When you extract the source tar file a new folder by name “postgresql-12.3” gets created. Please follow the commands step-by-step as copied below:

Step 7 

Please configure environment file you need to start and stop PostgreSQL server. In this post we have created it by name “” in the folder “/database/postgres”

Step 8 

You can grant 775 permission to the environment file

Step 9

Initialize PostgreSQL database or cluster using initdb

Step 10

Start PostgreSQL database using command pg_ctl.

Note: pg_ctl uses ‘-D’ option for the data directory and ‘-l’ option for log

Step 11

Test connecting to PostgreSQL from psql

How to debug PostgreSQL connectivity issues post installation:

  1. Stop PostgreSQL Server with ‘pg_ctl_stop’ and go to data directory of PostgreSQL
  2. open PostgreSQL configuration file pg_hba.conf file and append the entry given in the line copied below
    host all all md5
  3. Open PostgreSQL configuration file postgresql.conf and update listen_address with values below
    listen_addresses = ‘*’
  4. Start PostgreSQL Server using ‘pg_ctl start’