Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save marcellobenigno/b746fe2cd6dbcd8f1aeedb21ed619b7d to your computer and use it in GitHub Desktop.
Save marcellobenigno/b746fe2cd6dbcd8f1aeedb21ed619b7d to your computer and use it in GitHub Desktop.
Install PostGIS and GeoServer on Ubuntu 13.04

Install PostGIS and GeoServer on Ubuntu 13.04

PostGIS installation

Postgresql

Install the server:

sudo apt-get install postgresql-9.1 postgresql-contrib-9.1 pgadmin3

Execute the psql command under user postgres (sudo -u postgres)
and connect to database postgres (psql postgres):

sudo -u postgres psql postgres

In this sql shell change the password:

\password

Exit sql shell :

\quit

You can now fire-up pgAdmin III and test if you can connect to PostgreSQL

Postgis

Add PPA using:

sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable

Go to 'Ubuntu Software Center' and, from the menu, choose 'Edit -> Software Sources...'.
Change the distribution for http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu from 'raring' to 'quantal'.
Otherwise you will get an error message (could not open extension control file) when adding the PostGIS extension to your database.

Install postgis:

sudo apt-get install postgis postgresql-9.1-postgis-2.0 postgresql-9.1-postgis-2.0-scripts

Spatially enabling PostgreSQL

Connect to PostgreSQL using pgAdmin III and create a new database (e.g. geo). After creation look for a sub-node on your database called 'Extensions' add the following extensions (right click, new extension..).

  • postgis
  • postgis_topology

GeoServer installation

There are several ways to install GeoServer this document describes installing it on Tomcat7. Since we want a play HTML/JavaScript application to be able to access it we're going to hide it behind Apache2 which will also serve the bespoke application.

Server installation

Install Apache2 and Tomcat7:

sudo apt-get install apache2 tomcat7 tomcat7-admin

Install GeoServer war

wget http://sourceforge.net/projects/geoserver/files/GeoServer/2.4.0/geoserver-2.4.0-war.zip
unzip geoserver-2.4.0-war.zip geoserver.war
sudo mv geoserver.war /var/lib/tomcat7/webapps/

It can take a little while for the web app to load, check if it is running by redirecting your browser to: http://localhost:8080/geoserver login with username admin and password geoserver

Configure reverse proxy (Apache2)

Enable additional modules:

sudo a2enmod proxy proxy_ajp

Add directive by editing a new file:

sudo vi /etc/apache2/conf.d/proxy.conf

or

sudo nano /etc/apache2/conf.d/proxy.conf

Add the following line (note the port):

ProxyPass /geoserver ajp://localhost:8009/geoserver

Restart apache:

sudo service apache2 restart

If you now go to http://localhost/geoserver you will get a 503 error instead of a 404 since we first have to configure Tomcat7.

Configure AJP Connector (Tomcat7)

Open up the server.xml file:

sudo vi /etc/tomcat7/server.xml

or

sudo nano /etc/tomcat7/server.xml

Look for this fragment:

<!-- Define an AJP 1.3 Connector on port 8009 -->
<!--
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
-->

Change to:

<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" />

Save the file and restart Tomcat:

sudo service tomcat7 restart

If you now browse to http://localhost/geoserver you should see geoserver through apache2 reverse proxy. (first time could take a while since the app is restarting) If you still get a 503 error (temporary unavailable) first try a refresh, if that doesn't help, try and restart Apache2.

See Also

PostGIS install
PostGIS install Ubuntu 13.04
geoserver.org
Publishing a PostGIS Table on GeoServer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment