Table of Contents
Step 1: Install Java
curl -fsSL https://packages.adoptium.net/artifactory/api/gpg/key/public | sudo gpg --dearmor -o /usr/share/keyrings/artifactory.gpg.public
echo "deb [signed-by=/usr/share/keyrings/artifactory.gpg.public] https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | sudo tee /etc/apt/sources.list.d/adoptium.list
Antwort:
deb [signed-by=/usr/share/keyrings/artifactory.gpg.public] https://packages.adoptium.net/artifactory/deb jammy main
sudo apt update
sudo apt install temurin-8-jdk
sudo update-alternatives --config java
Kontrolle welche Java Version installiert ist:
sudo update-java-alternatives --list
oder auch:
java -version
Output: temurin-8-jdk-amd64 1081 /usr/lib/jvm/temurin-8-jdk-amd64
Step 2 Install Jetty 9
Home und WebApp Verzeichnis für Jetty anlegen:
sudo mkdir /opt/jetty
sudo mkdir -p /opt/webbase
Jetty9 downloaden:
cd /tmp
wget https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-distribution/9.4.46.v20220331/jetty-distribution-9.4.46.v20220331.tar.gz
Jetty 9 ins Verzeichnis opt/jetty entpacken:
sudo tar xzvf jetty-distribution-9.4.46.v20220331.tar.gz -C /opt/jetty --strip-components=1
sudo chown -R root /opt/jetty
create and setup jetty user
sudo mkdir /opt/jetty/temp
sudo useradd --user-group --shell /bin/false --home-dir /opt/jetty/temp jetty
for parameters see:
http://manpages.ubuntu.com/manpages/bionic/de/man8/useradd.8.html
sudo usermod -a -G jetty administrator
Setup correct permissions for jetty user
cd /opt/jetty
sudo chown jetty:jetty /opt/jetty/
sudo chgrp --recursive jetty /opt/jetty
sudo chown --recursive jetty webapps/ temp/ logs/
config jetty to use /opt/webbase/ for web directory
cd /opt/webbase/
ls.
should be empty
sudo java -jar /opt/jetty/start.jar --add-to-start=deploy,http,console-capture
Antwort:
INFO : webapp transitively enabled, ini template available with --add-to-start=webapp
INFO : server transitively enabled, ini template available with --add-to-start=server
INFO : security transitively enabled
INFO : servlet transitively enabled
INFO : console-capture initialized in ${jetty.base}/start.ini
INFO : http initialized in ${jetty.base}/start.ini
INFO : threadpool transitively enabled, ini template available with --add-to-start=threadpool
INFO : bytebufferpool transitively enabled, ini template available with --add-to-start=bytebufferpool
INFO : deploy initialized in ${jetty.base}/start.ini
MKDIR : ${jetty.base}/logs
MKDIR : ${jetty.base}/webapps
INFO : Base directory was modified
set correct permissions for user jetty:
sudo chown jetty:jetty /opt/webbase/
sudo chown --recursive jetty:jetty /opt/webbase/webapps
sudo chown --recursive jetty:jetty /opt/webbase/logs/
sudo mkdir /opt/webbase/work/
sudo chown jetty /opt/webbase/work/
Step 3 Create jetty service
Now, create a new file for Tomcat inside /etc/systemd/system directory:
sudo nano /etc/systemd/system/jetty9.service
add following configuration:
[Unit]
Description=Jetty 9 Web Application Server
Documentation=https://www.eclipse.org/jetty/documentation/current/
After=network.target
[Service]
# Configuration
Environment=JAVA_HOME=/usr/lib/jvm/temurin-8-jdk-amd64
#adoptopenjdk-8-hotspot-amd64
Environment="JETTY_HOME=/opt/jetty/"
Environment="JETTY_STATE=/opt/webbase/jetty.state"
Environment="TMPDIR=/opt/jetty/temp"
#Environment="JAVA_OPTS=-Djava.awt.headless=true"
Environment='JAVA_OPTIONS=-Dorg.eclipse.jetty.annotations.AnnotationParser.LEVEL=OFF\
-Djava.security.egd=file:/dev/./urandom -Djava.awt.headless=true\
-Xms512M -Xss512M -Xmx3G -XX:+UseConcMarkSweepGC\
-Dgeonetwork.resources.dir=/catalogue-data/resources\
-Dgeonetwork.data.dir=/catalogue-data\
-Dgeonetwork.backup.dir=/catalogue-data/data/backup\
'
EnvironmentFile=-/etc/default/jetty9
# Lifecycle
Type=simple
ExecStart=/opt/jetty/bin/jetty.sh run
ExecStop=/opt/jetty/bin/jetty.sh stop
ExecReload=/opt/jetty/bin/jetty.sh restart
SuccessExitStatus=143
Restart=on-abort
# Logging
SyslogIdentifier=jetty9
# Security
User=jetty
Group=jetty
PrivateTmp=yes
AmbientCapabilities=CAP_NET_BIND_SERVICE
NoNewPrivileges=true
#WorkingDirectory=/usr/share/jetty9/
#ReadWritePaths=/var/lib/jetty9/
[Install]
WantedBy=multi-user.target
Alias=jetty9.service
Editd default environmmet files for jetty
sudo nano /etc/default/jetty
# change to 'no' or uncomment to use the default setting in /etc/default/rcS
VERBOSE=yes
# Run Jetty as this user ID (default: jetty)
# Set this to an empty string to prevent Jetty from starting automatically
JETTY_USER=jetty
START_INI=/opt/webbase/start.ini
JETTY_HOME=/opt/jetty
JETTY_BASE=/opt/webbase
JETTY_CONF=/opt/jetty/etc/jetty.conf
JETTY_PID=/var/run/jetty.pid
JETTY_START=/opt/jetty/start.jar
Reload the systemd daemon:
sudo systemctl daemon-reload
Now you can start jetty server:
sudo systemctl enable jetty9.service
sudo systemctl start jetty9.service
check tomcat installation
http://localhost:8080/