geoserver

Installing geoserver on ubuntu 10.04

geoserver logo

Following the below steps should get the binary release of geoserver running on your 10.04 ubuntu install. This should also work generically for other versions of ubuntu. This process does not step you through securing or completely preparing the geoserver for production use, these details are outside the scope of this tutorial; please review the appropriate sections on security and running in a production environment via the geoserver documentation. Also if you are intending to run this geoserver in a production environment you should review any firewall and/or system settings that may be appropriate for your use case.

Install necessary supporting libraries and applications.

I think this is complete, but it may not be. If you run into any missing packages please indicate which packages also need to be installed in the comments so that others may benefit from your effort.


sudo apt-get update
sudo apt-get install gdal-bin openjdk-6-jdk openjdk-6-jre python-gdal unzip

Download the latest stable or latest release of geoserver.

In my case I grabbed Geoserver 2.1-RC4. These instructions should apply generically to the 2.0.3 release and hopefully others.


cd ~
wget http://downloads.sourceforge.net/geoserver/geoserver-2.1-RC4-bin.zip

Extract the release into your directory of choice.

In my case I chose '/opt' if you choose a different directory and release please substitute accordingly.


cd /opt
sudo unzip ~/geoserver-2.1-RC4-bin.zip 

Setup system for running geoserver.

Create a symlink

We want '/opt/geoserver' to point to '/opt/geoserver-RELEASE' so that we can easily upgrade geoserver at a later date.


sudo ln -s /opt/geoserver-2.1-RC4 /opt/geoserver

Download geoserver extensions.

Follow the extension download link for whichever version you downloaded in the previous step here. Grab any extensions you want to install. I grabbed the following;

  1. MySQL Data Store
  2. GDAL Coverage Store
  3. OGR output format

After downloading the extensions extract them to '/opt/geoserver/webapps/geoserver/WEB-INF/lib'.


cd ~
mkdir geoserver_extensions
cd geoserver_extensions
wget http://downloads.sourceforge.net/geoserver/geoserver-2.1-RC4-mysql-plugin.zip
wget http://downloads.sourceforge.net/geoserver/geoserver-2.1-RC4-gdal-plugin.zip
wget http://downloads.sourceforge.net/geoserver/geoserver-2.1-RC4-ogr-plugin.zip
find . -name \*.zip -exec unzip -o {} \;
sudo cp -rp *.jar /opt/geoserver/webapps/geoserver/WEB-INF/lib/

Add a geoserver user and group

Next we create a group and user that geoserver will run as:


sudo addgroup --system geoserver
sudo adduser --system --ingroup geoserver --no-create-home --disabled-password geoserver

Setup startup script

In order to start geoserver automatically at startup we need an init script. I grabbed the Debian/Ubuntu script located here.


cd /opt/geoserver/bin
sudo wget -O initd.sh http://docs.geoserver.org/latest/en/user/_downloads/geoserver_deb
sudo ln -s /opt/geoserver/bin/initd.sh /etc/init.d/geoserver
sudo chmod +x ./initd.sh

This script needs one slight modification to be better suited to ubuntu. Change the following line


# Default-Stop:      S 0 1 6

to


# Default-Stop:      0 1 6

This should be line 7 of the file.

Change ownership of the geoserver directory

The geoserver install directory should be owned by the geoserver user and group we just created.


sudo chown -R geoserver:geoserver /opt/geoserver-2.1-RC4/

Set the default startup parameters

Use your editor of choice and create a new file '/etc/default/geoserver'. The commented lines, starting with '#', indicate the default as provided in the startup script.


#USER=geoserver
#GEOSERVER_DATA_DIR=/home/$USER/data_dir
GEOSERVER_DATA_DIR=/opt/geoserver/data_dir

#GEOSERVER_HOME=/home/$USER/geoserver
GEOSERVER_HOME=/opt/geoserver

#PATH=/usr/sbin:/usr/bin:/sbin:/bin

#DESC="GeoServer daemon"

#NAME=geoserver

#JAVA_HOME=/usr/lib/jvm/java-6-sun
#DAEMON="$JAVA_HOME/bin/java"
JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk
DAEMON="$JAVA_HOME/bin/java"

#JAVA_OPTS="-Xms128m -Xmx512m"
JAVA_OPTS="-Xms128m -Xmx512m -server"

#PIDFILE=/var/run/$NAME.pid

#SCRIPTNAME=/etc/init.d/$NAME

Set the geoserver to launch on startup


sudo update-rc.d geoserver defaults

Setup log directories


sudo mkdir /opt/geoserver/webapps/geoserver/data/logs
sudo chown geoserver:geoserver /opt/geoserver/webapps/geoserver/data/logs/

Configure OGR based WFS output format

This allows geoserver to export a bunch of formats that geoserver does not handle natively. The conversion is done through the ogr library see OGR Simple Feature Library for more information on the capabilities of the gdal/ogr library. The following XML lets geoserver know where to find the ogr2ogr binary and the GDAL_DATA directory. Add the following XML to '/opt/geoserver/data_dir/ogr2ogr.xml'


<OgrConfiguration>
  <ogr2ogrLocation>/usr/bin/ogr2ogr</ogr2ogrLocation>
  <gdalData>/usr/share/gdal16</gdalData>
  <formats>
    <Format>
      <ogrFormat>MapInfo File</ogrFormat>
      <formatName>OGR-TAB</formatName>
      <fileExtension>.tab</fileExtension>
    </Format>
    <Format>
      <ogrFormat>MapInfo File</ogrFormat>
      <formatName>OGR-MIF</formatName>
      <fileExtension>.mif</fileExtension>
      <option>-dsco</option>
      <option>FORMAT=MIF</option>
    </Format>
    <Format>
      <ogrFormat>CSV</ogrFormat>
      <formatName>OGR-CSV</formatName>
      <fileExtension>.csv</fileExtension>
      <singleFile>true</singleFile>
      <mimeType>text/csv</mimeType>
    </Format>
    <Format>
      <ogrFormat>KML</ogrFormat>
      <formatName>OGR-KML</formatName>
      <fileExtension>.kml</fileExtension>
      <singleFile>true</singleFile>
      <mimeType>application/vnd.google-earth.kml</mimeType>
    </Format>
  </formats>
</OgrConfiguration>

Start the geoserver


sudo /etc/init.d/geoserver start

Test the geoserver

Now if everything has gone according to plan the geoserver should be running and accessible on port 8080. The default username and password are admin and geoserver respectively. You should review the security documentation for geoserver to properly secure the login and points of access.

Troubleshooting

Note that it can take geoserver quite a bit of time to actually bind to port 8080 and start responding. If you attempt to access geoserver on port 8080 and get an error message then wait a few minutes and try again. You can check to see if the geoserver is running by doing the following

  

ps aux | grep java

This should show something like the following indicating that the geoserver process is running.

  

5487 ?        Sl     0:21 /usr/lib/jvm/java-1.6.0-openjdk/bin/java -Xms128m -Xmx512m -server -DGEOSERVER_DATA_DIR=/opt/geoserver/data_dir -Djava.awt.headless=true -jar start.jar

If you see the geoserver process is running you can check to see if it has opened port 8080 and is listening for requests with the following


sudo lsof | grep TCP | grep geoserver

You should expect to see something like the following;


java      5487 geoserver  237u     IPv6      20420      0t0        TCP *:46378 (LISTEN)
java      5487 geoserver  249u     IPv6      20435      0t0        TCP *:http-alt (LISTEN)  

If you do not see the above but the java process is running just wait a few minutes as it can sometimes take a while for the geoserver to bind to port 8080.

Subscribe to RSS - geoserver