This page is targeted at Scala Developers, who want to get a / some simple web applications going, or create a dynamic web site using Scala. However nearly everything will also apply to people who want to use Java, Kotlin and other JVM language. Its not geared towards advanced professional Scala developers who will almost all be using other solutions. If like me you come to the Tomcat Server, with only the experience of running Apache vanilla servers, setting up Tomcat is significantly more complicated than the extreme simplicity of installing an Apache Vanilla server. Note referring to it as Apache Vanilla is my own naming scheme as referring to it just as "Apache" can be confusing. So here follows a list of steps for setting up Tomcat on your own Desktop, laptop, home server or VPS.
sudo apt install openjdk-21-jdk -y
Check the version
java -version
openjdk version "21.0.8" 2025-07-15
OpenJDK Runtime Environment (build 21.0.8+9-Ubuntu-0ubuntu124.04.1)
OpenJDK 64-Bit Server VM (build 21.0.8+9-Ubuntu-0ubuntu124.04.1, mixed mode, sharing)
There are default values here that you can change as you work down the page. Although once you've used a value, stick with it or you will create an inconsistent system. Insert your own values below. the data is used for page generation locally and is not sent back to our servers.
Create a new user and a new group of the same name and add it to the sudo group. For these examples we'll call it 'tommy'. I find it better to have a different name for the user than the folder we will create next. Again for desktop, laptop and home server this is not necessary and you can use your own username.sudo useradd -ms /bin/bash tommy
sudo passwd tommy
sudo useradd tommy sudo
sudo mkdir /opt/tomcat
sudo chown tommy:tommy /opt/tomcat
Switch user to tommy. Then change directory.
sudo su tommy
cd /opt/tomcat
Create a directory called Base inside the tomcat directory. This will be used for CatalinaBase and will allow you to keep configuration files to use
with multiple installs and major version changes of Apache.
tommy@computer:/opt/tomcat mkdir Base
tommy@computer:/opt/tomcat wget
https://dlcdn.apache.org/tomcat/tomcat-11/v11.0.12/bin/apache-tomcat-11.0.12.tar.gz
tommy@computer:/opt/tomcat sha512sum apache-tomcat-11.0.12.tar.gz | grep
alongsequenceoflettersanddigits
tommy@computer:/opt/tomcat tar xf apache-tomcat-11.0.12.tar.gz -C /opt/tomcat
tommy@computer:/opt/tomcat ln -s apache-tomcat-11.0.12 tom11
Then checking what we've got.
tommy@computer:/opt/tomcat ls
apache-tomcat-11.0.12 apache-tomcat-11.0.12.tar.gz Base tom11
tommy@computer:/opt/tomcat mkdir Base/logs
tommy@computer:/opt/tomcat mkdir Base/conf
tommy@computer:/opt/tomcat cp tom11/conf/server.xml tom11/conf/web.xml Base/conf
Create a home page for your server. Again not necessary if base and home are set to the same directory.
tommy@computer:/opt/tomcat mkdir -p Base/webapps/ROOT
tommy@computer:/opt/tomcat nano Base/webapps/ROOT/index.html
Copy the code below into the editor.
<!doctype html>
<html>
<head>
<title>Holding Page</title>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width,initial-scale=1.0'>
</head>
<body>
<h1>Holding Page</h1>
This is coming from a tomcat 11.0.12 server
</body>
</html>
sudo nano /etc/systemd/system/tom11.service
[Unit]
Description=Apache Tomcat 11.0 Web Application Container
After=network.target
[Service]
Type=forking
Environment="JAVA_HOME=/usr/lib/jvm/java-1.21.0-openjdk-amd64"
Environment="CATALINA_PID=/opt/tomcat/Base/temp/tomcat.pid"
Environment="CATALINA_HOME=/opt/tomcat/tom11/"
Environment="CATALINA_BASE=/opt/tomcat/Base/"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"
Environment="JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom"
ExecStart=/opt/tomcat/tom11/bin/startup.sh
ExecStop=/opt/tomcat/tom11/bin/shutdown.sh
User=tommy
Group=tommy
UMask=0007
RestartSec=10
Restart=always
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl start tom11
sudo systemctl status tom11
If status good, open a web page at localhost:8080
sudo sytemctl enable tom11
sudo apt install authbind
sudo touch /etc/authbind/byport/80
sudo chown tommy: /etc/authbind/byport/80
sudo chmod 500 /etc/authbind/byport/80
sudo nano /etc/systemd/system/tom11.service
change --> ExecStart=/opt/tomcat/tom11/bin/startup.sh
to --> ExecStart=authbind --deep /opt/tomcat/tom11/bin/startup.sh
sudo nano /opt/tomcat/Base/conf/server.xml
change <Connector port="8080" protocol
to <Connector port="80" protocol
sudo systemctl daemon-reload
sudo systemctl restart tom11