Setup PostgreSQL from binary

Pham Ngoc Quy
Apr 17, 2022

--

This story is a guild to install PostgresSQL from the binary.

Download specific PostgreSQL version:

wget https://ftp.postgresql.org/pub/source/v11.1/postgresql-11.1.tar.gz --no-check-certificate

Extract and install:

mkdir -p pg_src
tar xf postgresql-11.1.tar.gz --strip-components=1 -C pg_src
# create env folder
mkdir -p pg_env
cd pg_src
./configure --prefix=pg_env
make all -j4
make check
make install

Config environment:

cd pg_env
touch config.sh
# put this content to config.sh file:
export C_INCLUDE_PATH=<pth_to_env_folder>/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=<pth_to_env_folder>/include:$CPLUS_INCLUDE_PATH
export LD_LIBRARY_PATH=<pth_to_env_folder>/lib:$LD_LIBRARY_PATH
export PATH=<pg_env_path>/bin:$PATH

Initial data:

source pg_env/config.sh
mkdir -p pg_data
initdb -D pg_data

Start PostgreSQL:

pg_ctl -D pg_data start

--

--