Installing Geoserver with Tomcat on Ubuntu Server 14.04

The following guide describes how to set up Geoserver on an Ubuntu 14.04 LTS server using Tomcat7.

OpenJDK 7

Tomcat requires a Java JRE so we first want to install that (unless it's already installed):

sudo apt-get install openjdk-7-jre-headless

If there is a newer Java version available, you should go with the newer one!

Tomcat 7

Next we can install tomcat:

sudo apt-get install tomcat7 tomcat7-admin

Now you should configure the Tomcat users - removing the default ones and add the ones you need. To be more specific: we need a role with "manager-gui" and a user with this role to be able to use the manager gui.

sudo vi /var/lib/tomcat7/conf/tomcat-users.xml

<tomcat-users>
  <role rolename="manager-gui"/>
   <role rolename="admin"/>
  <user username="youUserName" password="yourPassword" roles="admin,manager-gui"/>
</tomcat-users>

Tuning Tomcat

To get a better performance for your application you should grant Tomcat more ressources:

sudo vi /etc/default/tomcat7

in JAVA_OPTS you should

  • set a higher value for the maximum heap size (xmx) for example -Xmx1024m (depending on the ressources available and the expected load) instead of the initial 128.
  • Also you should add the initial heap size parameter (xms) and set it's value to the same one as xsx, e.g. -Xms1024m

Next you can set a higher value for maxThreads. A rule of thumb is to set the value x200 times the number of cores:

sudo vi /etc/tomcat7/server.xml

Add to the <connector> for a server with two cores:

maxThreads="400"

Installing GeoServer

Now we can use elinks to download the geoserver .war archive from:

https://sourceforge.net/projects/geoserver/files/GeoServer/

unzip geoserver-2.7.2-war.zip

Hint: also ckeck for newer versions!

Opening the tomcat manager gui in a browser we can easily deploy the .war file.

Now Geoserver should be up an running - so first thing to do should be to login (admin/geoserver) and change your password.

Changing the 8080 port

It is considered good style to change the port from the Tomcat all time classic 8080 to the regular port 80.

Assuming you already got Apache2 installed on your server to my understanding the following would be the way to go:

sudo apt-get install libapache2-mod-proxy-html

activate the modules:

sudo a2enmod proxy
sudo a2enmod proxy_html
sudo a2enmod proxy_http
sudo service apache2 restart

Now configure the virtual host at

/etc/apache2/sites-available/

(you might want to look up the apache configuration)

            <VirtualHost *>
            ...
                    ProxyRequests Off
                    ProxyPreserveHost On
                    <Proxy *>
                          Order deny,allow
                          Allow from all
                    </Proxy>
                    ProxyPass /geoserver http://127.0.0.1:8080/geoserver
                    ProxyPassReverse /geoserver http://127.0.0.1:8080/geoserver
            ...
            </VirtualHost>

Now we have to restart Apache and afterwards should be able to reach Geoserver at http://yourIP/geoserver

sudo service apache2 restart

By the way, you might also be interested in securing your server!

Also - please let me know if you have suggestions to improve this howto (ed.rutkafunamnetadoeg@tkatnok)