Install PostgreSQL, PostGIS and OpenGeo on Ubuntu 14.04


Actually to install PostgreSQL, PostGIS and OpenGeo we can follow http://suite.opengeo.org/docs/latest/intro/installation/ubuntu/install.html#intro-installation-ubuntu-install.

wget -qO- http://apt.boundlessgeo.com/gpg.key | sudo apt-key add -
echo "deb http://apt.boundlessgeo.com/suite/v45/ubuntu/ trusty main" | sudo tee -a /etc/apt/sources.list.d/opengeo.list
sudo apt-get update
sudo apt-get install opengeo

Fixing libgdal1 Error

Unfortunately, I got an error:

Reading package lists... Done
Building dependency tree 
Reading state information... Done
The following packages were automatically installed and are no longer required:
 libarmadillo4 libarpack2 libbcmail-java libbcpkix-java libboost-thread1.54.0
 libcgal10 libcommons-jexl-java libcommons-lang3-java libdap11 libdapclient3
 libepsilon1 libexcalibur-logger-java libfreexl1 libgdal1h
 libgeronimo-javamail-1.4-spec-java libgeronimo-jms-1.1-spec-java
 libhdf4-0-alt libhdf5-7 libhtmlparser-java libhttpmime-java libjcharts-java
 libjtidy-java libkml0 liblwgeom-2.1.2 liblwgeom-2.1.6 libnetcdfc7 libodbc1
 libogdi3.2 libossp-uuid16 libspatialite5 liburiparser1 libxerces-c3.1
 libxstream-java linux-headers-3.13.0-32 linux-headers-3.13.0-32-generic
 linux-image-3.13.0-32-generic linux-image-extra-3.13.0-32-generic
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
 libgdal opengeo-client opengeo-dashboard opengeo-docs opengeo-server
 opengeo-tomcat7 pgdg-keyring postgis-2.1 postgresql-9.3
 postgresql-9.3-postgis-2.1 postgresql-client-9.3 postgresql-client-common
 postgresql-common
Suggested packages:
 oidentd ident-server locales-all postgresql-doc-9.3
The following NEW packages will be installed:
 libgdal opengeo opengeo-client opengeo-dashboard opengeo-docs opengeo-server
 opengeo-tomcat7 pgdg-keyring postgis-2.1 postgresql-9.3
 postgresql-9.3-postgis-2.1 postgresql-client-9.3 postgresql-client-common
 postgresql-common
0 upgraded, 14 newly installed, 0 to remove and 109 not upgraded.
Need to get 82.6 MB of archives.
After this operation, 222 MB of additional disk space will be used.
...
Preparing to unpack .../libgdal_1.11.1-1+opengeo_amd64.deb ...
Unpacking libgdal (1.11.1-1+opengeo) ...
dpkg: error processing archive /var/cache/apt/archives/libgdal_1.11.1-1+opengeo_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/libgdal.so.1', which is also in package libgdal1h 1.10.1+dfsg-5ubuntu1
Selecting previously unselected package postgis-2.1.
...
Errors were encountered while processing:
 /var/cache/apt/archives/libgdal_1.11.1-1+opengeo_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

The error caused by libgdal1 has duplicate item with different name libgdal1h. So, to fix the error, we can run the following commands:

sudo dpkg -P libgdal1h
sudo apt-get -f install

Voila! Our PostgreSQL, PostGIS and OpenGeo are ready on our machine.

Bonus: Activate PostGIS Shapefile and DBF loader

To access PostGIS Shapefile and DBF loader menu in pgAdmin III, we can edit /usr/share/pgadmin3/plugins.d/plugins.ini file by adding the following lines:

;
; pgShapeLoader (Linux):
;
Title=PostGIS Shapefile and DBF loader
Command=$$PGBINDIR/shp2pgsql-gui -U $$USERNAME -d $$DATABASE -p $$PORT -h $$HOSTNAME
Description=Open a PostGIS ESRI Shapefile or Plain dbf loader console to the current database.
KeyFile=$$PGBINDIR/shp2pgsql-gui
Platform=unix
ServerType=postgresql
Database=Yes
SetPassword=No
Advertisements