
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;
- MySQL Data Store
- GDAL Coverage Store
- 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-plugi...
wget http://downloads.sourceforge.net/geoserver/geoserver-2.1-RC4-gdal-plugin...
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.


Comments
One tiny glitch
Jeff - one tiny glitch that I had was when setting up log directories:
sudo mkdir /opt/geoserver/webapps/geoserver/data/logs
didn't work because the data directory didn't exist yet. I needed to:
sudo mkdir -p /opt/geoserver/webapps/geoserver/data/logs
Otherwise, I followed the instructions and was able to install the latest stable release (2.0.3 at this time) just fine.
After installing, I was able to see that everything worked via my browser by hitting:
http://localhost:8080/geoserver/web
JAVA_HOME problems
Hello Jeff. Thank you for posting such clear and concise instructions for installing Geoserver on Ubuntu.
I am, however, having the same problem with every approach I take to install. Everything seems to be fine, until I try to start Geoserver, when I get the JAVA_HOME environment is not defined. But it is defined. I have tried with Sun java as well as openjdk.
This was immediately after reboot:
quickstart@quickstart-VirtualBox:~$ cd geos/geoserver/bin
quickstart@quickstart-VirtualBox:~/geos/geoserver/bin$ sudo ./startup.sh
The JAVA_HOME environment variable is not defined
This environment variable is needed to run this program
quickstart@quickstart-VirtualBox:~/geos/geoserver/bin$ echo $JAVA_HOME
/usr/lib/jvm/java-6-openjdk
When I try to use the following command
sudo update-rc.d geoserver defaults
I get the error: file does not exist
Has anyone had this problem and fixed it?
JAVA_HOME woes
Aaron, it looks like you have skipped some of the steps I have outlined. Also your paths look different than what I outline above so hopefully you have extrapolated appropriately.
When attempting the 'sudo update-rc.d geoserver defaults' it is not finding the file '/etc/init.d/geoserver' please review the section 'Setup startup script' above and see if that helps get the file in place.
As an additional comment, regarding your JAVA_HOME.
If you are using bash, you need to export JAVA_HOME so either
export JAVA_HOME
or alternatively I usually declare and export environment variables in one fell swoop.
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk
Environment variables must be exported to be available to child processes within the bash shell. However, the startup process you are attempting is not covered by my documentation.
woes
Thanks for the reply Jeff. The funny thing is that the file does exist. I see it under etc/init.d/
I think I need to start over from the beginning. Again. You are using the openjdk version of java right? I read some (old) articles that say to use only sun version, so that is what I have been trying. I assume my problem is in having two versions of java (I have the correct one selected in java-alternatives). This time I will try to use native openjdk java. This makes two places where the system cannot find files that I know are there.
The instructions here are for
The instructions here are for openjdk, and it is certainly possible that having sun-jdk installed as well is leading to some confusion.
If you are following my instructions the file /etc/init.d/geoserver should be a symbolic link. Perhaps the target file is missing? From your previous post it looks like you installed in a directory other than /opt/geoserver perhaps you forgot to change the target for the following command referenced above?
sudo ln -s /opt/geoserver/bin/initd.sh /etc/init.d/geoserver
These instructions have been tested with ubuntu 10.04, while they should also work for other versions of ubuntu, I have not tested other versions.
Regarding sun vs. open jdk:
I have seen numerous posts for various applications mention that only sun's java implementation should be used. However, I have yet to see any issue with running openjdk. I'm not claiming that there are not issues with openjdk and certain applications, but rather that I have never encountered any issues.
woes
After restoring a backup, I am running into similar errors during install. It seems I am having problems with paths.
My original installation was a virtual machine appliance with ubuntu 10.10. I have noticed before when using terminal commands where leading / are used, I get an error. But when I remove the leading / it works
example:
quickstart@quickstart-VirtualBox:~$ cd /geos
bash: cd: /geos: No such file or directory
quickstart@quickstart-VirtualBox:~$ cd geos
quickstart@quickstart-VirtualBox:~/geos$
The first error I get installing Geoserver following your guide is when creating the symlink: (with and without leading /)
quickstart@quickstart-VirtualBox:~/geos$ sudo ln -s /geos/geoserver-2.1-RC4 /geos/geoserver
ln: creating symbolic link `/geos/geoserver': No such file or directory
quickstart@quickstart-VirtualBox:~/geos$ sudo ln -s geos/geoserver-2.1-RC4 geos/geoserver
ln: creating symbolic link `geos/geoserver': No such file or directory
Previously, I simply created the symlink in the file browswer, not from bash. I suspect the problems are all related, but I have very limited experience with linux and fixing this is above my pay scale, so to speak. Any guidance you can give is appreciated.
I would suggest installing
I would suggest installing verbatim from my instructions rather than transposing paths.
When you omit the leading '/' you are instructing the shell that the path is *relative* to your current working directory. This will result in differing results depending on your current directory. The leading slash is preferable as it unambiguously refers to a location in the file path.
Basic Linux usage is outside the scope of this documentation.
Path Issues
After installing once more, following your instructions verbatim, it worked. Thanks again for providing such concise, and current, instructions!
Can you provide more detail
Can you provide more detail on adding extensions, particularly MrSID format? Also, I am running the WAR version, could you provide steps that cover that install and how to setup your environment?
Thanks.
outside scope
This documentation is concerned strictly with the binary install of geoserver. For the WAR installation please review the Web Archive (WAR) documentation at http://docs.geoserver.org
Regarding MrSID, I'm unfamiliar with that format and it is proprietary. It sounds like a job more appropriate to GDAL, perhaps the following is helpful osgeo.org's MrSID wiki, but it sounds like something that GDAL supports.
Regardless both of these requests are outside the scope of this writeup. Good Luck!
About Sun vs OpenJDK
Hi,
about the Sun vs OpenJDK option, two observations:
initd
Hi,
I set up geoserver to run automaticaly after system boot using your instructions. This is what I get when I check if geoserver is running:
ps aux | grep java
110 7620 13.4 8.9 786872 140040 ? Sl 13:30 0:08 /usr/lib/jvm/java-6-sun/bin/java -Xms128m -Xmx512m -server -DGEOSERVER_DATA_DIR=/usr/local/geoserver/data_dir -Djava.awt.headless=true -jar start .jar
1000 9572 0.0 0.0 6152 644 pts/0 S+ 13:31 0:00 grep --color=auto java
sudo lsof | grep TCP | grep geoserver
java 7620 geoserver 202u IPv6 2855578513 TCP *:33630 (LISTEN)
and I can not connect to geoserver GUI via internet browser, funny thing is that this solution works on my Ubuntu Desktop running on localhost:8080 with absolutely no problems but It doesn't work on Ubuntu Server on port 80 (geoserver works on this Ubuntu Server on port 80 when I run it manualy).
Thank you in advance for any sugestions!
been through hours and hours of this
Hello, I have been at installing geoserver on ubuntu for about a week. Searched many sites and been on geoserver chat for hours, cant seem to get it. I am willing to pay someone to install this on my dedicated server. replay with a way to contact you. Thank!!
TCP *:http-alt (LISTEN) seems to fail
Hello,
I too want to thank your putting this install guide on the Internet.
By looking below, it appears that part is working. TCP *:http-alt (LISTEN) did not come up. Please let me know if you have run into this before. Thank you ! Harry
harry@harry-laptop:~/geoserver-2.1-RC4/bin$ sudo lsof | grep TCP | grep geoserver
lsof: WARNING: can't stat() fuse.gvfs-fuse-daemon file system /home/harry/.gvfs
Output information may be incomplete.
java 2450 geoserver 225u IPv6 74713 0t0 TCP *:46462 (LISTEN)
TCP *:http-alt (LISTEN) seems to fail --- never mind
Never mind. The problem is something else
sudo: /etc/init.d/geoserver: command not found
Hi,
This, most likely, is the real problem.
$:/opt/geoserver/bin$ sudo /etc/init.d/geoserver start
sudo: /etc/init.d/geoserver: command not found
Please let me know what I can look for solve this.
Thank you,
Harry
It looks like you skipped the
It looks like you skipped the section "Setup startup script"
TCP *:http-alt (LISTEN) is absent
This has been a tremendously detailed tutorial. Thank you. I have followed all the required steps, the results of the sudo lsof | grep TCP | grep geoserver command only yields the following:
java 1324 geoserver 217u IPv6 5336 0t0 TCP *:38705 (LISTEN)
The TCP *:http-alt (LISTEN) output is absent. Does any one know what the issue might be? I am installing this on Ubuntu 10.04 Server. I have designated the /var/www/geoserver as the home directory, so when I go to www.mydomain.com/geoserver, I get the list of files and folders in /var/www/geoserver.
The output of lsof | grep geoserver is below:
I'd appreciate your advice.
Thanks again.
Linux packages also available
Hi all. Note that OpenGeo now hosts GeoServer as standard RPM and DEB packages to make it even easier to install via standard means on Linux.
Here are some details on Ubuntu:
Installing GeoServer on Ubuntu
And CentOS too, for completeness:
Installing GeoServer on CentOS
tuff to install on ubuntu
i am also trying to install geoserver on ubuntu.
here i m getting a message of command not found
sudo: /etc/init.d/geoserver: command not found
please hep to resolve this
thanks
Jeff, Thanks a lot for great
Jeff,
Thanks a lot for great tutorial! Followed the steps and now can confirm it works without issues in 11.10.
r
great!
Really a great work of information about installing Geoserver. Very useful, thank you.
Thanks, have one question
First, thanks! This page has got me running and understanding the setup of geoserver.
I know this is written for Ubuntu but I used it to install on debian. Instead of installing in /opt I installed the package itself in /usr/lib/geoserver, the data_dir in /var/lib/geoserver/data_dir.
Do you agree that would be the prefered locations for debian?
great work
such an great work for ubuntu. i was looking for solution for my server
thanks
Post new comment