Update 'Installation Java 8 JDK & Jetty 9'

Kaimbacher 2022-06-30 12:44:30 +00:00
parent 0c2e06d6ff
commit 0d70c03514

@ -25,28 +25,127 @@ temurin-8-jdk-amd64 1081 /usr/lib/jvm/temurin-8-jdk-amd64
# Step 2 Install Jetty 9 # Step 2 Install Jetty 9
**Home Verzeichnis für Jetty anlegen:**\ ### Home und WebApp Verzeichnis für Jetty anlegen:
`sudo mkdir /opt/jetty` `sudo mkdir /opt/jetty` \
`sudo mkdir -p /opt/webbase`
**Jetty9 downloaden:** \ ### Jetty9 downloaden:
`cd /tmp` \ `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``` \ ```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:** \ ### 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 tar xzvf jetty-distribution-9.4.46.v20220331.tar.gz -C /opt/jetty --strip-components=1` \
`sudo chown -R root /opt/jetty` `sudo chown -R root /opt/jetty`
**create and setup jetty user** \ ### create and setup jetty user
`sudo mkdir /opt/jetty/temp` `sudo mkdir /opt/jetty/temp`
'sudo useradd --user-group --shell /bin/false --home-dir /opt/jetty/temp jetty`\ `sudo useradd --user-group --shell /bin/false --home-dir /opt/jetty/temp jetty`\
for parameters see: \ for parameters see: \
http://manpages.ubuntu.com/manpages/bionic/de/man8/useradd.8.html http://manpages.ubuntu.com/manpages/bionic/de/man8/useradd.8.html
sudo usermod -a -G jetty administrator `sudo usermod -a -G jetty administrator`
### Setup correct permissions for jetty user
```
cd /opt/jetty
sudo chown jetty:jetty /opt/jetty/
sudo chgrp -R jetty /opt/jetty
sudo chown -R 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
```
Reload the systemd daemon: \
`sudo systemctl daemon-reload`
Now you can start jetty server: \
`sudo systemctl enable jetty9.service` \
`sudo systemctl start jetty9.service`