DEV Community

Arunesh Choudhary
Arunesh Choudhary

Posted on

Postgres and PostGIS Installation

Install postgres 14 version


# Install dependencies 
sudo apt install build-essential libreadline-dev zlib1g-dev libssl-dev libxml2-dev libxslt-dev

# Download postgres 14
curl -OL https://ftp.postgresql.org/pub/source/v14.0/postgresql-14.0.tar.gz

# Extract the file
tar xvf postgresql-14.0.tar.gz

cd postgresql-14.0

# Configure the build
./configure --prefix=/usr/local/pgsql

# Run make
make

# Run make install
sudo make install
Enter fullscreen mode Exit fullscreen mode

Steps to install POSTGIS

Download: POSTGIS LINK

You will also need to install and/or build:

  • GEOS
  • Proj
  • GDAL
  • LibXML2
  • JSON-C

GEOS

GEOS WEBSITE

# Download GEOS
curl -OL https://download.osgeo.org/geos/geos-3.10.2.tar.bz2

# Extract the file
tar xvfj geos-3.11.2.tar.bz2

# Create a build directory
mkdir build-dir

# Change to the build directory
cd build-dir

# Run cmake
cmake ../geos-3.11.2 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local

# Run make
make 

# Test the build
ctest
# 100% tests passed, 0 tests failed out of 431

# Run make install
sudo make install
Enter fullscreen mode Exit fullscreen mode

Proj

PROJ WEBSITE


# Download proj
curl -OL https://download.osgeo.org/proj/proj-9.1.1.tar.gz

# Extract the file
tar xvf proj-9.1.1.tar.gz

# Create a build directory
mkdir build-dir

# Change to the build directory
cd build-dir

## Need to install sqlite 
# SQLite3 >= 3.11: headers and library for target architecture, and sqlite3 executable for build architecture.
sudo apt install sqlite3 
sudo apt-get install libsqlite3-dev
sudo apt-get install libtiff-dev

sudo apt update && sudo apt upgrade && sudo apt install curl && sudo apt-get install libcurl4-openssl-dev

# Run cmake
cmake ..

# Run make
cmake --build .

# Run make install
sudo cmake --build . --target install
Enter fullscreen mode Exit fullscreen mode

GDAL

GDAL WEBSITE

# Download GDAL
curl -OL https://github.com/OSGeo/gdal/releases/download/v3.6.4/gdal-3.6.4.tar.gz

# Extract the file
tar xvf gdal-3.6.4.tar.gz

# Create a build directory
mkdir build-dir

# Change to the build directory
cd build-dir

# Run cmake
cmake ../gdal-3.6.4
Enter fullscreen mode Exit fullscreen mode
# Run make
cmake --build .

# Run make install
sudo cmake --build . --target install
Enter fullscreen mode Exit fullscreen mode

POSTGIS


wget http://postgis.net/stuff/postgis-3.3.3dev.tar.gz
tar -xvzf postgis-3.3.3dev.tar.gz
cd postgis-3.3.3dev

# configure the build
./configure --with-pgconfig=/usr/local/pgsql/bin/pg_config --without-protobuf

# Run make
make

Enter fullscreen mode Exit fullscreen mode

Install AGE Extension


# Install Dependencies
sudo apt-get install build-essential libreadline-dev zlib1g-dev flex bison

# Download Postgres 14
sudo apt install postgresql-14 postgresql-server-dev-14

# check the version
pg_config

# Run make
sudo make install 

# Run make install
sudo make PG_CONFIG=/path/to/postgres/bin/pg_config install

Enter fullscreen mode Exit fullscreen mode

Top comments (0)