Manual Linux Tomcat Install¶
-
Download a Tomcat 11 install package:
-
Uncompress the Tomcat 11 install package:
-
Create a Tomcat user and set permissions:
-
Create/Edit the Tomcat service file:
and add this:
[Unit] Description=Tomcat 11 servlet container After=network.target [Service] Type=forking User=tomcat Group=tomcat Environment="JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64" Environment="JAVA_OPTS=-Djava.security.egd=file:///dev/urandom" Environment="CATALINA_BASE=/opt/tomcat/latest" Environment="CATALINA_HOME=/opt/tomcat/latest" Environment="CATALINA_PID=/opt/tomcat/latest/temp/tomcat.pid" Environment="CATALINA_OPTS=-Xms2G -Xmx4G -XX:SoftRefLRUPolicyMSPerMB=36000 -XX:-UsePerfData" ExecStart=/opt/tomcat/latest/bin/startup.sh ExecStop=/opt/tomcat/latest/bin/shutdown.sh [Install] WantedBy=multi-user.targetNote
The
-Xms2G -Xmx4Gvalues above are aLargeprofile starting point. See Memory sizing for guidance on choosing a profile, and Garbage collection tuning for larger deployments. -
Optional: You may choose to manage
CATALINA_OPTSby creating /opt/tomcat/latest/bin/setenv.sh (or by editingtomcat.serviceabove):#!/bin/sh # Prepend JVM Options CATALINA_OPTS="-XX:SoftRefLRUPolicyMSPerMB=36000 -XX:-UsePerfData ${CATALINA_OPTS}" # Append system properties CATALINA_OPTS="${CATALINA_OPTS} -Dorg.geotools.referencing.forceXY=true"Note
-Xjava options must be listed before any-Dsystem properties. -
Optional: By default Tomcat will use ¼ of system memory, to set a lower limit adjust
CATALINA_OPTSusingsetenv.sh(or by editingtomcat.serviceabove). -
Setup the Service
-
Test that Tomcat is running