How to compile PostGIS 2.0.1 on Ubuntu Server 12.04
PostGIS 2 has some exciting new goodies — including raster support — that I’m keen to use in the analysis of Mappiness data.
But the PostGIS package provided by Ubuntu 12.04 is still only at version 1.5, and the GEOS and GDAL packages are also too old to support the new version.
So — this is how I compiled PostGIS 2.0.1 and its dependencies on my GIS server.
I used checkinstall so as to be able easily to remove these libraries in future. And I installed GEOS and GDAL to /opt to keep them out of the way (I didn’t do the same for PostGIS because of a bug).
sudo /etc/init.d/postgresql stop # PostGIS 1.5.2 and its dependencies were installed already, so I # removed them sudo aptitude remove postgis postgresql-9.1-postgis \ libgdal1-dev libgdal1-1.7.0 gdal-bin python-gdal \ libspatialite2 libspatialite3 libgeos-dev libgeos-c1 # install any missing prerequisites sudo aptitude install build-essential checkinstall postgresql \ postgresql-server-dev-9.1 libjson0-dev libxml2-dev libproj-dev \ python2.7-dev swig cd ~ mkdir -p src # download and compile geos in /opt/geos cd ~/src/ wget http://download.osgeo.org/geos/geos-3.3.5.tar.bz2 tar xvjf geos-3.3.5.tar.bz2 cd geos-3.3.5/ ./configure --prefix=/opt/geos --enable-python make -j2 sudo checkinstall # uninstall with: dpkg -r geos # download and compile gdal in /opt/gdal cd ~/src/ wget http://download.osgeo.org/gdal/gdal-1.9.1.tar.gz tar xvzf gdal-1.9.1.tar.gz cd gdal-1.9.1/ ./configure --prefix=/opt/gdal --with-geos=/opt/geos/bin/geos-config \ --with-pg=/usr/lib/postgresql/9.1/bin/pg_config --with-python make -j2 sudo checkinstall # uninstall with: dpkg -r gdal # download and compile postgis 2 in default location cd ~/src/ wget http://www.postgis.org/download/postgis-2.0.1.tar.gz tar xvzf postgis-2.0.1.tar.gz cd postgis-2.0.1/ ./configure --with-geosconfig=/opt/geos/bin/geos-config \ --with-gdalconfig=/opt/gdal/bin/gdal-config make -j2 sudo checkinstall # uninstall with: dpkg -r postgis # for command-line tools, append this line to .profile/.bashrc/etc. export PATH=$PATH:/opt/geos/bin:/opt/gdal/bin # so libraries are found, create /etc/ld.so.conf.d/geolibs.conf # with these two lines: /opt/geos/lib /opt/gdal/lib # then sudo ldconfig sudo /etc/init.d/postgresql start # 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 /usr/share/postgresql/9.1/contrib/postgis-2.0/postgis_restore.pl \ /path/to/mydb.dump \ | sudo -u postgres psql -d mydb |
-
Anon
-
http://www.toddalbert.com/ Todd Albert
-
http://www.toddalbert.com/ Todd Albert
-
jawj
-
http://www.toddalbert.com/ Todd Albert