Tutorials  /  Linux Basics

Step-by-Step Guide: Install Tomcat on a Linux System

Ccentron Redaktion · May 2024 ·3 min read ·Linux Basics, Tutorial

Step 1: Preparations

Before installing Apache Tomcat, ensure that Java is installed on your system. The latest Long-Term Support (LTS) version is OpenJDK 21, released in September 2023.

Update your package sources:

Console
sudo apt update

Install the default JDK:

Console
sudo apt install default-jdk

Verify the Java installation:

Code
java -version
VM

Matching infrastructure at centron

No hardware needed to follow along: ccloud³ VMs with full root access start at €3.12 per month, billed by the hour and ready in seconds. Rent a cloud server →

Step 2: Set Up Tomcat User

It's recommended to run Tomcat under a dedicated user. Create a new user named 'tomcat':

Console
sudo useradd -r -m -U -d /opt/tomcat -s /bin/false tomcat

Step 3: Download Tomcat Package

As of January 2025, the latest stable version of Apache Tomcat is 10.1.x. APACHE TOMCAT

Download the latest version:

Console
wget https://downloads.apache.org/tomcat/tomcat-10/v10.1.34/bin/apache-tomcat-10.1.34.tar.gz

Step 4: Install Tomcat on Linux

Extract the downloaded archive to /opt/tomcat:

Console
sudo mkdir /opt/tomcat
sudo tar xf apache-tomcat-10.1.34.tar.gz -C /opt/tomcat --strip-components=1

Adjust permissions:

Console
sudo chown -R tomcat: /opt/tomcat
sudo sh -c 'chmod +x /opt/tomcat/bin/*.sh'

Step 5: Configure Tomcat Service

Create a systemd service file for Tomcat:

Console
sudo nano /etc/systemd/system/tomcat.service

Add the following content:

[Unit]

Description=Apache Tomcat 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/temp/tomcat.pid"

Environment="CATALINA_HOME=/opt/tomcat"

Environment="CATALINA_BASE=/opt/tomcat"

Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"

Environment="JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom"

ExecStart=/opt/tomcat/bin/startup.sh

ExecStop=/opt/tomcat/bin/shutdown.sh

User=tomcat

Group=tomcat

UMask=0007

RestartSec=10

Restart=always

[Install]

WantedBy=multi-user.target

Code

Reload the systemd daemon:

Console
sudo systemctl daemon-reload

Start and enable the Tomcat service:

Console
sudo systemctl start tomcat
sudo systemctl enable tomcat

Step 6: Allow Port 8080

If you have a firewall enabled, allow traffic on port 8080:

Console
sudo ufw allow 8080/tcp

Step 7: Verify Installation

Open your web browser and navigate to http://<your_server_ip>:8080. You should see the Apache Tomcat homepage.

Conclusion

By following these steps, you've successfully installed Apache Tomcat 10.1.x on your Linux system. This setup allows you to deploy Java Servlets and JSPs efficiently. For more information and updates, visit the official Apache Tomcat website.

Jetzt 200 € Guthaben sichern

Testen Sie Ihr Setup auf ccloud³

Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.

centron Redaktion Technische Redaktion

Das Redaktionsteam von centron schreibt Anleitungen aus dem Betriebsalltag: getestet auf unserer eigenen Plattform, betrieben im Rechenzentrum in Hallstadt bei Bamberg.

Kategorie Linux Basics
Teilen
Noch offene Fragen?

Unser Team hilft Ihnen bei Ihrem konkreten Setup weiter – von Menschen, die die Plattform selbst betreiben.

War dieses Tutorial hilfreich?

Ihre Antwort wird anonym gespeichert und hilft uns, die Tutorials zu verbessern.

Kommentare

Noch keine Kommentare – stellen Sie die erste Frage zu diesem Tutorial.

Zum Kommentieren anmelden

Kommentare stehen centron-Kunden offen. Melden Sie sich in Ihrem Konto an, um eine Frage zu diesem Tutorial zu stellen.

Weiterlesen

Das könnte Sie auch interessieren

Jetzt kostenlos anfangen

Melden Sie sich an und erhalten Sie in den ersten 60 Tagen ein Guthaben von 200 € bei centron.

Dieses Werbeangebot gilt nur für neue Konten. Angebot ausschließlich für Gewerbetreibende.

Jetzt loslegen Sales kontaktieren