0% found this document useful (0 votes)
43 views2 pages

Postgresql Installation

This document provides a step-by-step guide for installing PostgreSQL from source on a Ubuntu system. It includes instructions for downloading the source code, installing necessary libraries, creating a PostgreSQL user, setting up environment variables, initializing the data directory, and starting the PostgreSQL service. Additionally, it concludes with a command to check the database connection.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views2 pages

Postgresql Installation

This document provides a step-by-step guide for installing PostgreSQL from source on a Ubuntu system. It includes instructions for downloading the source code, installing necessary libraries, creating a PostgreSQL user, setting up environment variables, initializing the data directory, and starting the PostgreSQL service. Additionally, it concludes with a command to check the database connection.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1)Download Postgresql source code and unzip the tar file

#Login to the sudo user

sudo su -

#Download source code

wget https://ftp.postgresql.org/pub/source/v9.5.15/postgresql-9.5.15.tar.gz

tar -xvzf postgresql-9.5.15.tar.gz

2)Install needed libraries

sudo apt update

sudo apt-get install gcc

sudo apt install libreadline-dev

sudo apt install zlib1g-dev

sudo apt intall make

3)Start installation from source Code

#Run below commands for installation

cd postgresql-9.5.15

./Configure && make && make install

4)Create postgres user and data directory

#Create postgres user

adduser postgres

#change from default from shell to bash

sudo usermod -s /bin/bash postgres

#Create postgres folder

mkdir /home/postgres

#To create the default settings in a new user's home directory

sudo cp -a /etc/skel/. /home/postgres

#Setting ownershi & permissions

sudo chown -R postgres:postgres /home/postgres/

sudo chmod -R 755 /home/postgres

5)Create Data directory and assign postgres ownership

mkdir -p /cluster/data

chown -R postgres:postgres /cluster/data


6)Setup basic environment variables

su - postgres

vi ~/.profile

#Add end of the line

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

export PGDATA=/cluster/data

export PGUSER=postgres

export PGPORT=5432

export PGDATABASE=postgres

#Execute below command

source ~/.profile

7)Initialize the data directory and start the PostgreSQL service:

initdb -D /cluster/data

pg_ctl -D /cluster/data -l logfile start

8)Check database connection

psql -p 5432

Ref: https://nestcode.co/en/blog/install-postgresql-13-from-source-in-ubuntu-204

You might also like