Install Geoserver on Ubuntu Server

Install Geoserver on Ubuntu Server

Geoserver is a JAVA based application developed to ease the styling and sharing of geospatial data using Opensource technology. It follows the standards of the?Open Geospatial Consortium (OGC)?and thus has wide application in a variety of industries. Geoserver’s?website?states more clearly regarding its usability and documentation.

Let us begin by understanding the requirements and steps in order to install and run geoserver successfully


Installing Geoserver in a GUI-based system such as Windows, Mac or even Ubuntu GUI is a piece of cake ??. Have a look at my blogs about ???windows??? or about ???mac???installations, If you have GUI access for Ubuntu machine you can follow similar steps for mac.

But If you just have a connection to ssh terminal and that’s all. Roll up your sleeves and follow this blog!

First things first, try to use the terminal as an admin user so you don’t have to type password zillion times.Make yourself the owner and go to the root directory :

sudo -u root -i        

also, make sure you have an updated system


sudo apt-get update        

Step 1: Check/Install JAVA 8

Geoserver currently only supports JAVA-JRE-8, you can install it by typing

No alt text provided for this image


sudo apt-get install openjdk-8-jdk

sudo apt-get install openjdk-8-jre        

To cross-check installation, type

java -version         

and you should get something similar to this as an output

Step 2: Installation of Postgres ( Optional )

Most of the time, we prefer to save the data in the database so that it can be accessible can used by a lot of other applications as well. Sure?Shapefile?is better for saving Geospatial data, but it comes with a lot of compromises as well (e.g. not been able to read it/edit without software, etc.). I personally prefer?Postgres?over other?RDBMS, since it is by far the world’s most advanced open-source relational database, and to put the cherry on top of this cake, it also allows us to leverage geospatial capabilities by installing and using?PostGIS, PostGIS allows user to query the data using geospatial component ( buffer, within, intersects, etc. )


We’ll start by first installing the latest PostgreSQL version:


sudo apt -y install gnupg2

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

echo "deb https://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" |sudo tee  /etc/apt/sources.list.d/pgdg.list

sudo apt update

sudo apt install postgis postgresql-13-postgis-3        

and then type?psql?to open a window like this:

No alt text provided for this image


you can get out of PostgreSQL by typing?\q?and then?exit

Now, you can install PostGIS:

sudo apt install postgis        

Step 3: Downloading GeoServer

Downloading GeoServer without GUI might get a little tricky since we can’t simply do?sudo apt get geoserver?(Not at least by the time I’m writing the article ?? ). But no worries!! If you visit the GeoServer build page, https://build.geoserver.org/geoserver/ you can select the interested geoserver version. For now, we'll use main which is latest stable version.

We’ll create a new directory and put GeoServer in it

cd /usr/share
mkdir geoserver
cd geoserver

wget https://build.geoserver.org/geoserver/main/geoserver-main-latest-bin.zip        

This will download a?geoserver-main-latest-bin.zip?file in a GeoServer folder that we just created.

The next step is to unzip the?geoserver-main-latest-bin.zip.

unzip geoserver-main-latest-bin.zip        

This will unzip the GeoServer folder, and if you type?ls?in the command line, you’ll see something like this:

No alt text provided for this image


Finally, we’ll set up a variable to make it workable

echo "export GEOSERVER_HOME=/usr/share/geoserver" >> ~/.profile
. ~/.profile        

and make sure that the user is the owner of this folder as well

sudo chown -R USER_NAME /usr/share/geoserver/        

Step 4: Once everything is done!

You are there!!

Geoserver is successfully installed and you can now turn it up.

head over to?bin?directory and open?startup.sh?file

cd bin
sh startup.sh        
No alt text provided for this image


Then you’ll see stuff beaming up on your terminal, and when you finally see a text something like in the photo, your GeoServer is up and running.

Step 5: Making Geoserver ready for usage!

Since you have installed GeoServer with Terminal, I’m guessing this is for your server, which means we need to be sure that the GeoServer and data inside it is accessible publicly. The default port for GeoServer is?8080,?which must be open in your server in order to be able to access GeoServer from anywhere, another business we need to take care of is the?CORS policy, Geoserver allows users to get the data as a JSON, XML, etc. hence it is quite important to secure your data. If you try to use GeoServer right now, if you access the layers from another, it’ll show you a CORS error.

In order to solve this, you need to uncomment few lines in a?web.xml?file, which is generally located at

geoserver/webapps/geoserver/WEB-INF


Once you reach in a folder using the terminal, you can open and edit the file using?vim. You can install vim by simply typing

sudo apt install vim        

and then you can open the?web.xml?file using vim:

sudo vim web.xml        

Vim allows us to modify the file from the terminal. click?I (Captial i)?to get into insert mode and use arrow keys to move down until you find a line with?CORS in Jetty?written.

Once you find it, Uncomment the code and again search for CORS, Since we are not using tomcat, you can keep CORS related to tomcat commented. You can find the third and final code for CORS.

Once both of these CORS codes are uncommented. You can hit the?Esc?key to get out of edit mode and type?:wq?to save the changes in web.xml

Now you can head back to the bin folder again and run the GeoServer like

Step 4.If you get an error while accessing GeoServer, Make sure to head back to the web.xml file and double-check all comments and uncomments.

And we are done!

In this blog, we succeeded to install JAVA, PostgreSQL, PostGIS, Geoserver using terminal!!
Sajiya Salat

DevOps Engineer | AWS Community Builder, Contract DevOps Engineer

5 个月

hello Krishna Lodha why didnt you use microservice approach for setting up geoserver?

回复
Usmanov Kanat

Python Developer

1 年

Thanks for Sharing.

Shai Sussman

??Data Scientist ????Python ??GIS Developer

1 年

it seems like in version 2.23 openjdk-8-jdk, is not sufficent, and default-jre satisfies the requirement.

Karim C.

Linux System Administrator

2 年

This is not production development which will serve under any domain?

Jordan Bess

Solutions Architect and Developer (expert in Geospatial Data)

2 年

Thanks - users that can work with Rasters that are cached as map tiles (MBTILES or GPKG) already can check out our powerful and flexible solutions https://portfolio.techmaven.net/apps/geospatial-servers-on-premise-or-at-edge/ That can run on a laptop at the edge or on a production web server. Includes build in advanced map viewers/editors and ability to make self service portal. https://www.youtube.com/watch?v=asK7xRfb7YQ&t=10sl

要查看或添加评论,请登录

Krishna Lodha的更多文章

  • How to Generate Contour on the fly on GeoServer

    How to Generate Contour on the fly on GeoServer

    Digital Elevation Models (DEM) are crucial for terrain analysis, and contour lines are one of the best ways to…

    1 条评论
  • 5 Python Libraries for Earth Observation

    5 Python Libraries for Earth Observation

    Earth observation has become a cornerstone of the GIS industry, driven by the exponential growth in satellite missions…

    2 条评论
  • Digital Terrain Models in GIS: A Practitioner’s Guide to DSM, DTM, and DEM

    Digital Terrain Models in GIS: A Practitioner’s Guide to DSM, DTM, and DEM

    Picture yourself flying over a city in a helicopter. Looking down, you see buildings piercing the sky, trees dotting…

    3 条评论
  • Get Sentinel Data within seconds in?Python

    Get Sentinel Data within seconds in?Python

    With the development of STAC specification, accessing Satellite datasets have become easy and standard approach. This…

    1 条评论
  • The Ultimate Guide of Downloading OSM Data using ChatGPT

    The Ultimate Guide of Downloading OSM Data using ChatGPT

    Open Street Map is a collaborative mapping project that aims to create a free and editable map of the world. Unlike…

    7 条评论
  • Simple way of authentication for Geoserver

    Simple way of authentication for Geoserver

    Geoserver is an amazing tool which allows users to share spatial data of vector and raster type using OGC services like…

    1 条评论
  • Extending Openlayers capabilites

    Extending Openlayers capabilites

    If you have used openlayers in the past, you know it's capabilities very well. Openlayers allows users to put…

    10 条评论
  • Editing Feature directly via Geoserver

    Editing Feature directly via Geoserver

    GeoServer, an open-source geospatial server, provides powerful capabilities for serving and managing geospatial data…

    5 条评论
  • Custom popups in Geoserver

    Custom popups in Geoserver

    When we upload any layer to Geoserver, we can check the data on click by going in to Layer preview and display layer as…

    1 条评论
  • Install Geoserver on Mac OS

    Install Geoserver on Mac OS

    I use mac for most of my development purpose, and it’s already lil scary trying to install executables and libraries…

    3 条评论

社区洞察

其他会员也浏览了