Building PostgreSQL 18.x - linux-on-ibm-z/docs GitHub Wiki

Building PostgreSQL

Below versions of PostgreSQL are available in respective distributions at the time of creation of these build instructions:

  • RHEL 8.10 has 10.23
  • RHEL (9.4, 9.6, 9.7) have 13.22
  • RHEL (10.0, 10.1) have 16.10
  • SLES 15 SP7 has18.1
  • Ubuntu 22.04 has 14.18
  • Ubuntu 24.04 has 16.9
  • Ubuntu 25.10 has 17.5

The instructions provided below specify the steps to build PostgreSQL version 18.1 on Linux on IBM Z for

  • RHEL(8.10, 9.4, 9.6, 9.7, 10.0, 10.1)
  • Ubuntu (22.04, 24.04, 25.10)

General Notes:

  • When following the steps below please use a standard permission user unless otherwise specified.
  • A directory /<source_root>/ will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it.

1. Build using script

If you want to build postgreSQL using manual steps, go to STEP 2.

Use the following commands to build postgreSQL using the build script. Please make sure you have wget installed.

wget -q https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/PostgreSQL/18.1/build_postgresql.sh

# Build PostgreSQL
bash build_postgresql.sh   [Provide -t option for executing build with tests]

If the build completes successfully, follow the notes at the end of the script and go to STEP 3. In case of error, check logs for more details or go to STEP 2 to follow manual build steps.

2. Build and Install PostgreSQL

2.1. Install dependencies

export SOURCE_ROOT=/<source_root>/
  • RHEL 8.10
    sudo yum install -y git wget gcc gcc-c++ tar make readline-devel zlib-devel bison flex glibc-langpack-en procps-ng diffutils patch curl libicu-devel
    
  • RHEL (9.4, 9.6, 9.7, 10.0, 10.1)
    sudo yum install -y git wget gcc gcc-c++ tar make readline-devel zlib-devel bison flex glibc-langpack-en procps-ng diffutils patch curl libicu-devel perl-FindBin perl-File-Compare
    
  • SLES 16.0
    sudo zypper --non-interactive refresh
    sudo zypper --non-interactive install -y gawk glibc-locale diffutils libicu coreutils util-linux bison flex wget gcc gcc-c++ make git tar zlib-devel readline-devel patch curl
    sudo ln -sf /usr/sbin/useradd /usr/bin/useradd
    echo 'postgres ALL=(ALL) NOPASSWD: ALL' | sudo tee -a /etc/sudoers
    
  • Ubuntu (22.04, 24.04, 25.10)
    sudo apt-get update
    sudo apt-get install -y bison flex wget build-essential git gcc tar make zlib1g-dev libreadline-dev patch curl
    

2.2. Create postgres user

sudo useradd postgres -m -U
sudo passwd postgres

Note: Please note that /usr/sbin is available in PATH environment variable.

2.3. Download PostgreSQL source code

cd $SOURCE_ROOT
wget https://ftp.postgresql.org/pub/source/v18.1/postgresql-18.1.tar.gz
tar xf postgresql-18.1.tar.gz

2.4. Build and Install PostgreSQL

cd $SOURCE_ROOT/postgresql-18.1
./configure --without-icu
make
make check
sudo make install

Note: Before you run make check make sure LANG environment variable is not set. unset LANG if it is already set.

2.5. Update the PATH variable

export PATH=$PATH:/usr/local/pgsql/bin

3. Set up PostgreSQL server (Optional)

3.1. Create PostgreSQL data directory to store data and make postgres user as the owner

sudo mkdir -p /usr/local/pgsql/data
sudo chown postgres:postgres /usr/local/pgsql/data

3.2. Initialize PostgreSQL data directory as postgres user

su postgres -s /bin/bash
export PATH=$PATH:/usr/local/pgsql/bin
cd /home/postgres/
initdb -D /usr/local/pgsql/data/

Note: Please make sure the directory /usr/local/ has sufficient read and execute permissions when initializing.

3.3. Start the PostgreSQL server

pg_ctl -D /usr/local/pgsql/data/ -l logfile start

References: