Skip to content

Instantly share code, notes, and snippets.

@krishnaglodha
Created September 27, 2023 04:36
Show Gist options
  • Save krishnaglodha/a529c329108d77099aba925a9f800b11 to your computer and use it in GitHub Desktop.
Save krishnaglodha/a529c329108d77099aba925a9f800b11 to your computer and use it in GitHub Desktop.
PostGIS Installation on ubuntu
#!/bin/bash
# Add the PostgreSQL APT repository for the latest version
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
# Import the repository signing key
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
# Update the package list
sudo apt update
# Install PostgreSQL and PostGIS
sudo apt install -y postgresql postgresql-contrib postgis
# Enable the PostGIS extension in PostgreSQL
sudo -u postgres psql -c "CREATE EXTENSION postgis;"
# Optionally, enable the topology extension as well
sudo -u postgres psql -c "CREATE EXTENSION postgis_topology;"
# Restart PostgreSQL to apply the changes
sudo systemctl restart postgresql
echo "PostGIS has been installed and enabled."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment