Whilst investigating performance improvements to my GeoServer installation I 
have been installing it quite a few times. To make things faster, I developed a 
script to automate most of the basic stuff I needed from a clean install of 
Ubuntu 20
Just in case it is of any use to others I post it here.
It might not be the tidies scripting and I run it as root (I know thats not 
ideal and feel free to change it, but it is a local test server)

I always create a folder /data/ and usually run Apache as the front end to 
terminate SSL and provide authentication.

Russ

#!/bin/bash
#
#    build_geoserver - Automates most of the tasks of installing Geoserver and 
PostgreSQL
#
#    Copyright Russ Hore, 2010, All Rights Reserved
#
#    This script is free for use: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#
#############################################################
# Do an update and clean up before continuing
apt-get update --assume-yes
apt-get upgrade --assume-yes
apt-get dist-upgrade --assume-yes
apt autoremove --assume-yes


#############################################################
# Install Tomcat 9
apt-get install tomcat9 --assume-yes
apt-get install tomcat9-admin --assume-yes
apt-get install tomcat9-common --assume-yes
apt-get install tomcat9-user --assume-yes

#############################################################
# Install GDAL utilities
apt-get install gdal-bin --assume-yes
apt-get install gdal-data --assume-yes
apt-get install python-gdal --assume-yes

#############################################################
# Install Apache2
apt-get install apache2 --assume-yes

#############################################################
# Install PHP
apt-get install php7.4 --assume-yes
apt-get install php7.4-common --assume-yes
apt-get install php7.4-curl --assume-yes
apt-get install php7.4-gd --assume-yes
apt-get install php7.4-json --assume-yes
apt-get install php7.4-pgsql --assume-yes
apt-get install php7.4-xml --assume-yes

#############################################################
# Install CertBot to use LetsEncrypt certificates for SSL
apt-get install certbot --assume-yes

#############################################################
# Unzip is always useful
apt-get install unzip --assume-yes

#############################################################
# Install Geoserver
# NB Need to check for the latest version
#################################################
## Now install Geoserver 2.17.1
#################################################
# 1) Get the WAR file
wget 
"http://sourceforge.net/projects/geoserver/files/GeoServer/2.17.1/geoserver-2.17.1-war.zip";
# 2) Create a directory to hold the zip file
mkdir GS2.17.1
# 3) Cop yhte zip file to the directory
mv geoserver-2.17.1-war.zip GS2.17.1
# 4) Change into the directory and unzxip the file
cd GS2.17.1
unzip geoserver-2.17.1-war.zip
# 5) Stop tomcat whilst we copy the war file in (I know you don't need to but 
why not?)
service tomcat9 stop
# 6) Copy the war file to the Tomcat web apps directory
cp geoserver.war /var/lib/tomcat9/webapps/
# 7) Re-start Tomcat
service tomcat9 start

#################################################
## Now configure Geoserver 2.17.1
#################################################
# I always create a data folder at / to hold all the GeoServer stuff
mkdir /data/
chown tomcat:tomcat /data/

#################################################
## Need to make /data/ readable by Tomcat9
#
# Edit the following file and add  the follwoing line unere the # Secunrity 
section
# ReadWritePaths=/data/
#
#################################################
vi /lib/systemd/system/tomcat9.service 

#################################################
## Make Geoserver point to /data/
#
# Uncomment DATA_DIR and point it to /data/
#################################################
vi /var/lib/tomcat9/webapps/geoserver/WEB-INF/web.xml

# Re-start Tomcat
systemctl restart tomcat9
systemctl daemon-reload

#################################################
#################################################
## Install PostgreSQL with PostGIS
# CHECK the latest version fo PostgreSQLL and PostGIS
#################################################
apt-get install postgresql-12-pgrouting --assume-yes
apt-get install postgresql-12-postgis-3 --assume-yes
apt-get install postgresql-12-postgis-3-scripts --assume-yes

# Install the OpenStreetMap to PostgreSQL utilities
apt-get install osm2pgsql --assume-yes

#############################################################
#############################################################
#
echo "Now you should be able to log on to Geoserver with the default 
username/password"
echo "Log in now and do the following;"
echo "1) Change the admin password"
echo "2) Delete the file /data/security/masterpw.info"
echo "3) Set the default user/group to use digest password"
echo ""
#############################################################

_______________________________________________
Geoserver-users mailing list

Please make sure you read the following two resources before posting to this 
list:
- Earning your support instead of buying it, but Ian Turton: 
http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines: 
http://geoserver.org/comm/userlist-guidelines.html

If you want to request a feature or an improvement, also see this: 
https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer


Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to