GeoServer
Description
GeoServer is a FOSS server allowing users to work with and visualize geospatial data. The software can publish data from any major spatial data source using open standards. [1]
Installation and setup
GeoServer with Ubuntu 22.04 LTS (using Docker)
Please check the non-Docker installation first, it's a bit more complicated but gives you more control over your data.
Assuming you got your Ubuntu Server running, start the terminal and follow the steps
First we install Docker, if not already done so[2]
sudo apt update
sudo apt upgrade
- First add the repository to the latest community edition of Docker
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
- Add the official repository
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
- Install the dependencies
sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release -y
- Do an update again
sudo apt update
- Install the docker
sudo apt-get install docker-ce docker-ce-cli containerd.io -y
- Add the user of your choice to the Docker group
sudo usermod -aG docker $USER
Now we add the geoserver container using the own data directory[3]
sudo docker pull docker.osgeo.org/geoserver:2.23.4
docker run --mount type=bind,src=/MY/DATADIRECTORY,target=/opt/geoserver_data -it -p8081:8081 docker.osgeo.org/geoserver:2.23.4
Change /MY/DATADIRECTORY into whatever you wish and 8081 is the port you wish to use, feel free to appoint another port.
GeoServer on VirtualBox with Ubuntu 22.04 LTS (native - no Docker!)
The following is a step by step tutorial how to set up GeoServer on Ubuntu 22.04 LTS Server
The tutorial is based on the Tutorial by Hitesh Jethva [4] with slight alterations for the versions as mentioned below (up-to-date at the moment of this writing) and focused on the MAPANAN project in the City of Baguio, Philippines to host Orthophotos by UAS in GeoTIFF format.
Software used for deployment, installation and setup
Version | Download link | Version used for this tutorial | Release date |
---|---|---|---|
Ubuntu Server | Ubuntu | 22.04.4 LTS | 16 Feb 2024 |
GeoServer | GeoServer | 2.25.0 | 19 Mar 2024 |
Specifications of hardware
Hosting imagery doesn't really take that much resources, just to get it to work. I've got it running 150GB of high-res drone imagery on just 2 cores and 4GB RAM. Though speed is an issue and to get an acceptable responsiveness you should dedicate a bit more hardware.
Installation and setup for Ubuntu
Assuming you got your Ubuntu Server running, start the terminal and follow the following guidelines
sudo apt update
sudo apt upgrade
- Verify if you got java already installed:
java --version
sudo apt install openjdk-11-jdk -y
- There's other versions feel free to suit your needs, GeoServer is tested to work with 8, 11 and 17 (11 more stable and tested)[5]wget https://sourceforge.net/projects/geoserver/files/GeoServer/2.25.0/geoserver-2.25.0-bin.zip
Latest as of Mar 19 2025, or go for the older "stable" one athttps://geoserver.org/release/stable/
sudo mkdir /usr/share/geoserver
sudo apt install unzip
sudo unzip -d /usr/share/geoserver/ geoserver-2.25.0-bin.zip
sudo groupadd geoserver
Have a group to access the directory feel free to use a different namesudo useradd -m -U -s /bin/false user1
- Replace "user1" with any other name of your choosing for the user(s) to access the shared foldersudo usermod -aG geoserver user1
sudo usermod -aG geoserver user2
sudo chgrp -R geoserver /usr/share/geoserver
chmod -R g+rwX /usr/share/geoserver
sudo chown -R user1:geoserver /usr/share/geoserver
sudo nano /usr/lib/systemd/system/geoserver.service
- and enter the following into the document
[Unit] Description=GeoServer Service After=network.target [Service] Type=simple User=geoserver Group=geoserver Environment="GEOSERVER_HOME=/usr/share/geoserver" ExecStart=/usr/share/geoserver/bin/startup.sh ExecStop=/usr/share/geoserver/bin/shutdown.sh [Install] WantedBy=multi-user.target
- and enter the following into the document
systemctl daemon-reload
systemctl enable --now geoserver
systemctl status geoserver
- this will output if your service is loaded and active- you can now go to the website: http://yourip:8080/geoserver/ and it'll show you the main login
- default username/password is admin/geoserver - on the left side you can go to Security->Users, Groups, Roles->Users/Groups->admin now you can change your administrator username and password and at this point your done setting up the GeoServer.Proceed with configuration
Troubleshooting
- If you on Ubuntu Server run into 403 or 115 errors, these are server errors! Quite often from local servers which are IP-restrictive.[6]
- Open your sources.list with an editor
sudo nano /etc/apt/sources.list
- at this point find all references to local servers i.e. http://ph.archive.ubuntu.com/ubuntu and replace with http://archive.ubuntu.com/ubuntu
- Open your sources.list with an editor
- If you run into errors "The method 'ftp' is unsupported and disabled by default." run the following command[7]
echo 'Dir::Bin::Methods::ftp "ftp";' | sudo tee -a /etc/apt/apt.conf.d/99local-ftp
- If you run into "couldn't open data connection" errors for some downloads during
sudo apt-get install xxxx
while others download just fine, do the following:sudo apt-get update --fix-missing
sudo apt-get install xxxx
- repeat these steps until you got them all, in some cases you may have to repeat this many times but you'll get them all eventually.
- Geoserver has some rights/ownership specifics. The folder with the drone images should be properly set:
- sudo chown -R username:groupname foldername
- sudo chmod -R 770 foldername
- To Remove/change Java and install another version: https://askubuntu.com/questions/84483/how-to-completely-uninstall-java
Configuration
First go to Workspaces | |
Create a new workspace | |
Click on the newly created workspace and set WMTS, WMS and if required enable the settings and fill out the data as you see fit | |
Next add new stores as you see fit. I arranged them per quarter of the year so newer orthographic images automatically overwrite older | |
Select from the list of options the ImageMosaic under the Raster Data Sources |
Maintenance of Stores for Mosaic Imagery
The web interface doesn't provide an automated update for stores. Copying a new orthographic image to the directory of a given workspace won't thus automatically update. One can manually wipe clean the corresponding files in the directory or wipe out the caching and then manually re-scan the directory. This is time consuming and prone to errors.
Setting up a cron job for this is the easiest way, it may need root permission[8]
- enter in the shell to work as root
sudo -i
- create a file for instance in the root home folder
vi updategeoserver
- Enter the code below into that file so its command can be executed by root
#!/bin/bash curl -v -u admin:geoserver -XPOST -H "Content-type: text/plain" -d "file:///path/to/the/mosaic/folder" "http://localhost:8080/geoserver/rest/workspaces/<workspace_name>/coveragestores/<store_name>/external.imagemosaic"
|
|
The cron job itself the easiest, assuming still logged on as root
- Execute the follow command to enter the cron job file for root
crontab -e
- The following line will update the Geoserver store for that specific directory once per hour
*/60 * * * * ./updategeoserver
At this point your Geoserver for that specific store/workspace will update automatically once an hour.
To clean a geoserver folder one can just create a script file analog to the update command and wipe out the geoserver generated files
- enter in the shell to work as root
sudo -i
- create a file for instance in the root home folder
vi cleangeoserver
- Enter the code below into that file so its command can be executed by root
#!/bin/bash rm ../folder/*.dbf |
* example: ../../var/snap/nextcloud/common/nextcloud/data/HikeAndMap/files/Survey/UAV/2_OUTPUT/orthophoto/2024/2024.dbf
|
work in progress
Linux commands
getent group group_name
|
Users in a group[9] |
cat /etc/group
|
Lists all groups[10] |
cat /etc/passwd
|
Lists all users[11] |
userdel -r usernamed
|
Deletes a user from Linux '-r' deletes $HOME folder[12] |
ls -ld directory
|
Get permissions of directory[13] |
sudo -i
|
Elevate to root[14] |
docker container ls -a
|
Show all containers[15] |
docker container rm ID
|
Remove container with ID[15] |
systemctl list-unit-files | grep enabled
|
find all enabled services using systemctl |
systemctl restart geoserver.service
|
restart the service |
Important linux locations
/var/snap/nextcloud/common/nextcloud/data
|
Data directory of NextCloud using Snap installation[16] |
/usr/share/geoserver/webapps/geoserver/WEB-INF/classes/org/geoserver/web/img/logo.png
|
This is the location to overwrite the Geoserver icon in the upper left corner with your own [17] |
/usr/share/geoserver/start.ini
|
File that holds startup data like port number |
Tile optimizations and practical experience
Hosting the high resolution orthographic images comes with a caveat, namely the sheer amount of data results in huge file sizes. In JOSM, QGIS and similar software for both the mapper and for the data consumer it's quite slow in the loading the data and the delays the mapper gets on his end using JOSM are frustrating to staff and students using the hosted imagery for mapping activities as well as data consumer activities using OpenStreetMap in conjunction with orthographic imagery in QGIS.
We found by trial and error that smaller individual tiles hosted instead of large single files speeds up this process especially when zooming-in and -out in JOSM on higher zoom levels.
Therefore we use predefined squared cut-lines to split the large single survey orthographic images into smaller parts.
GDAL, splitting orthographic images
placeholder
References
- ↑ https://github.com/geoserver/geoserver
- ↑ https://www.zdnet.com/article/docker-101-how-to-install-docker-on-ubuntu-server-22-04/
- ↑ https://docs.geoserver.org/maintain/en/user/installation/docker.html
- ↑ https://cloudinfrastructureservices.co.uk/how-to-install-geoserver-server-on-ubuntu-20-04-tutorial-step-by-step/
- ↑ https://docs.geoserver.org/maintain/en/user/production/java.html#production-java
- ↑ https://askubuntu.com/questions/104695/how-do-i-change-mirrors-in-ubuntu-server-from-regional-to-main
- ↑ https://askubuntu.com/questions/1187236/how-to-re-enable-ftp-on-secondary-ubuntu-debian-server-to-pull-updates-from-main
- ↑ https://docs.geoserver.org/latest/en/user/rest/imagemosaic.html#updating-an-image-mosaic-contents
- ↑ https://linuxhandbook.com/list-users-in-group-linux/
- ↑ https://www.howtouselinux.com/post/list-all-groups-linux
- ↑ https://phoenixnap.com/kb/how-to-list-users-linux
- ↑ https://linuxize.com/post/how-to-delete-users-in-linux-using-the-userdel-command/
- ↑ https://stackoverflow.com/questions/338037/how-to-check-permissions-of-a-specific-directory
- ↑ https://askubuntu.com/questions/230476/how-to-solve-permission-denied-when-using-sudo-with-redirection-in-bash#230482
- ↑ 15.0 15.1 https://linuxize.com/post/how-to-remove-docker-images-containers-volumes-and-networks/
- ↑ https://help.nextcloud.com/t/where-and-how-are-the-acutal-files-stored/30565
- ↑ https://geoserver-users.narkive.com/KMR2K56I/how-to-change-favicon-of-geoserver