-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathbuild_postgis.sh
39 lines (33 loc) · 1.25 KB
/
build_postgis.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
################################################################################
#
# This script downloads PostgreSQL from the official web site into ./workdir
# then builds it.
#
# Usage: ./build_postgis.sh pg_version postgis_version
# pg_version is a PostgreSQL version to be installed like 16.0.
# postgis_version is a PostGIS version to be installed.
#
# Requirements
# - be able to connect to the PostGIS official web site by wget.
#
################################################################################
POSTGRESQL_VERSION=$1
POSTGIS_VERSION=$2
cd ./workdir
cd postgresql-${POSTGRESQL_VERSION}
# Install necessary dependencies
sudo apt update
sudo apt install -y build-essential libxml2-dev libgeos-dev libproj-dev libgdal-dev libjson-c-dev libprotobuf-c-dev protobuf-c-compiler
GEOS_CONFIG_PATH=$(which geos-config)
# Download and compile PostGIS
cd contrib
wget http://download.osgeo.org/postgis/source/postgis-${POSTGIS_VERSION}.tar.gz
tar -xzf postgis-${POSTGIS_VERSION}.tar.gz
mv postgis-${POSTGIS_VERSION} postgis -v
cd postgis
echo " - PostGIS directory"
export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH
./configure --with-pgconfig=/usr/local/pgsql/bin/pg_config --with-geosconfig=$GEOS_CONFIG_PATH
make
sudo make install