Gis Tricks

Installing postgres 9.6 postgis 2.3 pgrouting 2.3.1.

Installing postgres 9.6 postgis 2.3 pgrouting 2.3.1.

After a while of not updating I wanted to update my qgis and postgis to the latest available. This turned out quite a struggle. In this post the lessons I learned and how I solved it in the end. The post is mostly for my own benefit in case I have to do this again in the nearby future.

First of all I used this brilliant post on stackoverflow on how to thorougly purge and reinstall postgresql and used it for both qgis and postgres.

remove all redundant shit:


sudo apt-get remove 9.5 main
sudo pg_dropcluster 9.6 main
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get -f install
sudo apt-get autoremove qgis
sudo apt-get --purge remove qgis

It turns out it is almost impossible to install the lastest versions of postgres and postgis on ubuntu 14.04. So I made an update to xenial.
This cost me the most time. After installing xenial it was almost a breeze:

but while doing this install on ubuntu 14.04 I learned that a remove of postgres is not complete unles you also remove the cluster otherwise it will simply add a new cluster to your system and also it will use a different port than the standard 5433.

Here is what i tried:



sudo apt-get install postgresql-9.6-postgis-2.3
 sudo pg_createcluster 9.6 main --start

sudo service --status-all | grep postgres
 sudo service postgresql start
 sudo -u postgres psql postgres
 \password postgres

then install pgrouting:

 
 sudo apt-get install postgresql-9.3-pgrouting

 

cannot connect. pff. is it running on the right port? or is there a problem with the packaging? with the following I discovered which port my install is using now

sudo netstat -nlp | grep postgres

result 5434
so to connect we do:

sudo -u postgresĀ  psql -h localhost -p 5434 postgres

After the xenial update I did the following:

<pre>sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt xenial-pgdg main" &amp;gt;&amp;gt; /etc/apt/sources.list'

wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -

sudo apt-get install postgresql-9.6-postgis-2.3

sudo apt-get install postgresql-9.6-pgrouting

Then I got the same error as on stackoverflow and solved it like this:

<pre>sudo apt-get install libopenscenegraph100v5 
sudo apt-get install libopenthreads20
then we connect to postgres and check the versions:


select version();

“PostgreSQL 9.6.1 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.3.1-14ubuntu2) 5.3.1 20160413, 64-bit”


select postgis_full_version(); 

“POSTGIS=”2.3.1 r15264″ GEOS=”3.5.0-CAPI-1.9.0 r4084″ SFCGAL=”1.2.2″ PROJ=”Rel. 4.9.2, 08 September 2015″ GDAL=”GDAL 1.11.3, released 2015/09/16″ LIBXML=”2.9.3″ LIBJSON=”0.11.99″ RASTER”


<code>select pgr_version()</code>

“(2.3.1,v2.3.1,963f95d,master,1.58.0)”

Leave a Reply

Your email address will not be published. Required fields are marked *

three + 4 =