Last active
December 15, 2015 10:59
-
-
Save YanhaoYang/5250148 to your computer and use it in GitHub Desktop.
Commands for installing postgis copied from How to compile PostGIS 2.0.1 on Ubuntu Server 12.04 (http://blog.mackerron.com/2012/06/01/postgis-2-ubuntu-12-04/)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment