DEV Community

Arunesh Choudhary
Arunesh Choudhary

Posted on

1

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

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay