Skip to content

Instantly share code, notes, and snippets.

@gpprojekt-marcin
Last active August 29, 2015 14:03
Show Gist options
  • Save gpprojekt-marcin/d4d097aa866e9b3024f2 to your computer and use it in GitHub Desktop.
Save gpprojekt-marcin/d4d097aa866e9b3024f2 to your computer and use it in GitHub Desktop.
cd ~
mkdir -p src
# First install PostgreSQL 9.3, plus contributed packages and any missing prerequisites
# ===
# the following is necessary on 13.04 (and possibly 12.10?)
sudo apt-get install postgresql-common --target-release raring
# then
sudo apt-get install postgresql-9.3 postgresql-server-dev-9.3 postgresql-contrib-9.3 build-essential checkinstall libjson0-dev libxml2-dev libproj-dev python2.7-dev swig
# Now for GEOS, GDAL and PostGIS
# ===
# download and compile geos in /opt/geos
cd ~/src/
wget http://download.osgeo.org/geos/geos-3.4.1.tar.bz2
tar xvjf geos-3.4.1.tar.bz2
cd geos-3.4.1/
./configure --prefix=/opt/geos --enable-python
make -j2
sudo checkinstall # uninstall with: sudo dpkg -r geos
# download and compile gdal in /opt/gdal
cd ~/src/
wget http://download.osgeo.org/gdal/1.10.0/gdal-1.10.0.tar.gz
tar xvzf gdal-1.10.0.tar.gz
cd gdal-1.10.0/
./configure --prefix=/opt/gdal --with-geos=/opt/geos/bin/geos-config --with-pg=/usr/lib/postgresql/9.3/bin/pg_config --with-python
make -j2
sudo checkinstall # uninstall with: sudo dpkg -r gdal
# download and compile postgis in default location
cd ~/src/
wget http://download.osgeo.org/postgis/source/postgis-2.1.0.tar.gz
tar xvzf postgis-2.1.0.tar.gz
cd postgis-2.1.0/
./configure --with-geosconfig=/opt/geos/bin/geos-config --with-gdalconfig=/opt/gdal/bin/gdal-config
make -j2
sudo checkinstall # uninstall with: sudo dpkg -r postgis
# for command-line tools:
echo 'export PATH="$PATH:/opt/geos/bin:/opt/gdal/bin:/usr/lib/postgresql/9.3/bin"' >> .bashrc
# so libraries are found:
echo '/opt/geos/lib
/opt/gdal/lib' | sudo tee /etc/ld.so.conf.d/geolibs.conf
sudo ldconfig
# restart postgres
sudo /etc/init.d/postgresql restart
# restore a pg_dump -Fc backup from an earlier PostGIS version
echo 'create database mydb;' | sudo -u postgres psql
echo 'create extension postgis; create extension postgis_topology;' | sudo -u postgres psql -d mydb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment