Install PostgreSQL 17.4 from Source code

PostgreSQL 17.4 Installation from Source Code (Step-by-Step Guide for Linux)
Author: Rajasekhar Amudala PostgreSQL DBA Guide Source Installation Oracle Linux 9

Install PostgreSQL 17.4
Using Source Code

pgdb01 · 192.168.2.71 Oracle Linux 9 PostgreSQL 17.4 Author: Rajasekhar Amudala

STEP 01

Environment

ParameterValue
Host Namepgdb01
IP Address192.168.2.71
OSLinux 9 (Oracle Linux)
PostgreSQL Version17.4
Data Directory/pgData/pgsql/17.4
WAL Directory/pgWal/pgsql/17.4
BIN Directory/pgbin/pgsql/17.4/bin
Software Staging/pg_Backup/stage

STEP 02

Install Dependencies

root@pgdb01 ~ #
[root@pgdb01 ~]# dnf install -y readline-devel zlib-devel gcc make \ libicu-devel openssl-devel bison flex wget tar

# Packages installed / upgraded: Installed: bison flex gcc libicu-devel make openssl-devel readline-devel zlib-devel glibc-devel glibc-headers kernel-headers ncurses-devel ...Complete! [root@pgdb01 ~]#

STEP 03

Create postgres User

root@pgdb01 ~ #
[root@pgdb01 ~]# useradd postgres [root@pgdb01 ~]# passwd postgres Changing password for user postgres. New password: Retype new password: passwd: all authentication tokens updated successfully. [root@pgdb01 ~]#

STEP 04

Download PostgreSQL Source

root@pgdb01 ~ #
[root@pgdb01 ~]# mkdir -p /pg_Backup/stage [root@pgdb01 ~]# cd /pg_Backup/stage

[root@pgdb01 stage]# wget https://ftp.postgresql.org/pub/source/v17.4/postgresql-17.4.tar.gz

-- 2026-04-21 20:22:48 -- Resolving ftp.postgresql.org... 151.101.211.52 Length: 28056622 (27M)

postgresql-17.4.tar.gz 100% [========================>] 26.76M 10.2MB/s in 2.6s

2026-04-21 20:22:51 (10.2 MB/s) - 'postgresql-17.4.tar.gz' saved [28056622/28056622]
[root@pgdb01 stage]#

STEP 05

Extract Source

root@pgdb01 — /pg_Backup/stage
[root@pgdb01 stage]# tar -xvf postgresql-17.4.tar.gz postgresql-17.4/ postgresql-17.4/.cirrus.star ... (many files) ... postgresql-17.4/src/tutorial/syscat.source

[root@pgdb01 stage]# ls -ltr total 27404 drwxrwxr-x. 6 root root 4096 Feb 18 2025 postgresql-17.4 -rw-r--r--. 1 root root 28056622 Feb 18 2025 postgresql-17.4.tar.gz
[root@pgdb01 stage]# cd postgresql-17.4 [root@pgdb01 postgresql-17.4]# pwd /pg_Backup/stage/postgresql-17.4 [root@pgdb01 postgresql-17.4]#

STEP 06

Configure Build

Note configure only checks system dependencies and prepares Makefiles. It records your install path (/pgbin/pgsql/17.4) internally but does not create the bin directory or install anything yet.
root@pgdb01 — /pg_Backup/stage/postgresql-17.4
[root@pgdb01 postgresql-17.4]# ./configure --prefix=/pgbin/pgsql/17.4 --with-pgport=5432
checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking which template to use... linux ... config.status: creating GNUmakefile config.status: creating src/Makefile.global config.status: creating src/include/pg_config.h configure complete. [root@pgdb01 postgresql-17.4]#

STEP 07

Compile Source

Error Encountered First make run failed: missing Perl module FindBin.pm. Fixed by installing perl perl-core perl-ExtUtils-MakeMaker, then running make clean before retrying.
Step 1 — Fix missing Perl module
# First make attempt — error: [root@pgdb01 postgresql-17.4]# make .. .. Can't locate FindBin.pm in @INC ... make[2]: *** [Makefile:141: bki-stamp] Error 2 make: *** [src/Makefile.global:384: submake-generated-headers] Error 2

# Fix: install Perl modules [root@pgdb01 postgresql-17.4]# dnf install -y perl perl-core perl-ExtUtils-MakeMaker Complete!

# Clean up partial build [root@pgdb01 postgresql-17.4]# make clean rm -rf tmp_install/ portlock/ [root@pgdb01 postgresql-17.4]#
Step 2 — Successful make
[root@pgdb01 postgresql-17.4]# make

make -C ./src/backend generated-headers ... (compiling all source files) ... make[2]: Nothing to be done for 'all'. make[2]: Leaving directory '.../src/test/perl' make[1]: Leaving directory '.../src' make -C config all make[1]: Nothing to be done for 'all'. make[1]: Leaving directory '.../config' [root@pgdb01 postgresql-17.4]#

STEP 08

Install PostgreSQL

Note The /pgbin/pgsql/17.4/ bin directory is created automatically by make install.
root@pgdb01 — /pg_Backup/stage/postgresql-17.4
[root@pgdb01 postgresql-17.4]# make install

... (installing binaries, libraries, headers) ... /usr/bin/install -c -m 755 ./install-sh '/pgbin/pgsql/17.4/lib/pgxs/config/install-sh' /usr/bin/install -c -m 755 ./missing '/pgbin/pgsql/17.4/lib/pgxs/config/missing' [root@pgdb01 postgresql-17.4]#

# Verify installation layout [root@pgdb01 17.4]# ll /pgbin/pgsql/17.4/ total 16 drwxr-xr-x. 2 root root 4096 Apr 21 21:06 bin drwxr-xr-x. 6 root root 4096 Apr 21 21:06 include drwxr-xr-x. 4 root root 4096 Apr 21 21:06 lib drwxr-xr-x. 6 root root 4096 Apr 21 21:06 share [root@pgdb01 17.4]#

STEP 09

Install PostgreSQL Contrib (Extensions)

Option A Run from the source root directory
Option A
[root@pgdb01 postgresql-17.4]# make -C contrib install
OR
Option B Run from the contrib subdirectory (shown below)
Option B — root@pgdb01
[root@pgdb01 ~]# cd /pg_Backup/stage/postgresql-17.4/contrib [root@pgdb01 contrib]# make ... compiling vacuumlo, pg_trgm, hstore, pg_stat_statements, etc. ... make[1]: Leaving directory '.../contrib/vacuumlo'

[root@pgdb01 contrib]# make install ... installing .so files and extension SQL scripts ... /usr/bin/install -c -m 644 ./unaccent.rules '/pgbin/pgsql/17.4/share/tsearch_data/' make[1]: Leaving directory '.../contrib/unaccent' [root@pgdb01 contrib]#

# Fix ownership and permissions [root@pgdb01 ~]# chown -R postgres:postgres /pgbin /pgData /pgWal /pgArch /pg_Backup [root@pgdb01 ~]# chmod 700 /pgbin /pgData /pgWal /pgArch /pg_Backup [root@pgdb01 ~]#

STEP 10

Set Environment Variables

As postgres User Switch to the postgres OS user and add the following exports to ~/.bash_profile.
postgres@pgdb01 — ~/.bash_profile
[root@pgdb01 17.4]# su - postgres [postgres@pgdb01 ~]$

# Add to ~/.bash_profile: export PGHOME=/pgbin/pgsql/17.4 export PATH=$PGHOME/bin:$PATH export PGDATA=/pgData/pgsql/17.4

# Reload profile
[postgres@pgdb01 ~]$ . .bash_profile[postgres@pgdb01 ~]$ which psql /pgbin/pgsql/17.4/bin/psql [postgres@pgdb01 ~]$

STEP 11

Validation 1 — pg_config

postgres@pgdb01
[postgres@pgdb01 ~]$ /pgbin/pgsql/17.4/bin/pg_config

BINDIR = /pgbin/pgsql/17.4/bin DOCDIR = /pgbin/pgsql/17.4/share/doc INCLUDEDIR = /pgbin/pgsql/17.4/include LIBDIR = /pgbin/pgsql/17.4/lib SHAREDIR = /pgbin/pgsql/17.4/share PGXS = /pgbin/pgsql/17.4/lib/pgxs/src/makefiles/pgxs.mk CONFIGURE = '--prefix=/pgbin/pgsql/17.4' '--with-pgport=5432' CC = gcc VERSION = PostgreSQL 17.4 [postgres@pgdb01 ~]$

STEP 12

Initialize Database Cluster

postgres@pgdb01 — initdb
[postgres@pgdb01 ~]$ mkdir -p /pgData/pgsql/17.4 /pgWal/pgsql/17.4

[postgres@pgdb01 ~]$ /pgbin/pgsql/17.4/bin/initdb \ --pgdata=/pgData/pgsql/17.4 \ --waldir=/pgWal/pgsql/17.4 \ --wal-segsize=128

The files belonging to this database system will be owned by user "postgres". The database cluster will be initialized with locale "en_SG.UTF-8". The default database encoding has accordingly been set to "UTF8". The default text search configuration will be set to "english".fixing permissions on existing directory /pgData/pgsql/17.4 ... ok fixing permissions on existing directory /pgWal/pgsql/17.4 ... ok creating subdirectories ... ok selecting dynamic shared memory implementation ... posix selecting default "max_connections" ... 100 selecting default "shared_buffers" ... 128MB selecting default time zone ... Asia/Singapore creating configuration files ... ok running bootstrap script ... ok performing post-bootstrap initialization ... ok syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections initdb: hint: You can change this by editing pg_hba.conf or using -A/--auth-local.

Success. You can now start the database server using: /pgbin/pgsql/17.4/bin/pg_ctl -D /pgData/pgsql/17.4 -l logfile start [postgres@pgdb01 ~]$

STEP 13

Start PostgreSQL Instance

postgres@pgdb01
[postgres@pgdb01 ~]$ /pgbin/pgsql/17.4/bin/pg_ctl -D /pgData/pgsql/17.4 -l logfile start

waiting for server to start.... done server started [postgres@pgdb01 ~]$

STEP 14

Validation

postgres@pgdb01 — Process Check
[postgres@pgdb01 ~]$ ps -ef | grep postgres

postgres 62707 1 0 21:50 ? /pgbin/pgsql/17.4/bin/postgres -D /pgData/pgsql/17.4 postgres 62708 62707 0 21:50 ? postgres: checkpointer postgres 62709 62707 0 21:50 ? postgres: background writer postgres 62711 62707 0 21:50 ? postgres: walwriter postgres 62712 62707 0 21:50 ? postgres: autovacuum launcher postgres 62713 62707 0 21:50 ? postgres: logical replication launcher
postgres@pgdb01 — psql Checks
[postgres@pgdb01 ~]$ psql -c "SELECT VERSION();"version ----------------------------------------------------------------------- PostgreSQL 17.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 11.5.0 (1 row)

[postgres@pgdb01 ~]$ psql psql (17.4) Type "help" for help.postgres=# \l List of databases Name | Owner | Encoding | Collate -----------+----------+----------+------------- postgres | postgres | UTF8 | en_SG.UTF-8 template0 | postgres | UTF8 | en_SG.UTF-8 template1 | postgres | UTF8 | en_SG.UTF-8 (3 rows)postgres=# \du List of roles Role name | Attributes -----------+---------------------------------------------- postgres | Superuser, Create role, Create DB, Replication, Bypass RLSpostgres=# \q [postgres@pgdb01 ~]$
Installation Complete PostgreSQL 17.4 is compiled from source, running, and validated on pgdb01.

STEP 15

Next Steps

Next 01
Configure Memory & Connections
postgresql.conf — shared_buffers, max_connections, work_mem
Next 02
Configure Client Access
pg_hba.conf — host, method, CIDR rules
Next 03
Enable WAL Archiving
archive_mode = on & archive_command in postgresql.conf
Next 04
Take a Base Backup
pg_basebackup -D /pg_Backup/base ...
⚠ Disclaimer Your use of any information or materials in this guide is entirely at your own risk. It is provided for educational purposes only. It has been tested internally; however, we do not guarantee it will work for you. Always validate in a test environment before applying to production.
RA

Rajasekhar Amudala

PostgreSQL DBA · br8dba@gmail.com
linkedin.com/in/rajasekhar-amudala ↗