This assumes PostgreSQL 11.7. PostgreSQL is easy to install whether using yum or building from source.
Pre-checks
GNU make Version
Confirm it is version 3.80 or higher.
make --version
Install gcc
sudo yum -y install gcc
readline-devel Package
sudo yum -y install readline-devel
zlib-devel Package
sudo yum -y install zlib-devel
Create OS User
groupadd -g 1101 postgres
useradd -u 1101 -g postgres -G postgres -d /home/postgres postgres
passwd postgres
PostgreSQL Installation (performed as postgres user)
Download Source & Extract
wget https://ftp.postgresql.org/pub/source/v11.7/postgresql-11.7.tar.gz
tar xvfz postgresql-11.7.tar.gz
If you need to modify the source code, do so at this point.
cd ./postgresql-11.7/contrib/pg_trgm
vi ./trgm.h
#Comment out KEEPONLYALNUM
Build & Install
cd $HOME/postgresql-11.7
./configure --prefix=$HOME/pgsql/11
make
make install
PostgreSQL Initialization
Create $PGDATA
mkdir -p /home/postgres/pgsql/11/data
Initialize DB
sudo su - postgres
whoami
export PGDATA=/home/postgres/pgsql/11/data
/home/postgres/pgsql/11/bin/initdb --pgdata=$PGDATA
/home/postgres/pgsql/11/bin/pg_ctl start --pgdata=$PGDATA
/home/postgres/pgsql/11/bin/pg_ctl status --pgdata=$PGDATA
Connect and Verify Version
[postgres@post11db bin]$ ./psql
psql (11.7)
Type "help" for help.
postgres=#
postgres=# select version();
version
--------------------------------------------------------------------------------------------------------
PostgreSQL 11.7 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-6), 64-bit
(1 row)
Reference
Chapter 16. Installation from Source Code https://www.postgresql.jp/document/11/html/installation.html