How to Install Apache Tomcat 10 on Ubuntu 24.04
Step-by-step tutorial on how to install Tomcat on Ubuntu 24.04 LTS. Setup Apache Tomcat 10 with OpenJDK 21, systemd service, web manager, and UFW firewall.

6 min read
Step-by-step tutorial on how to install Tomcat on Ubuntu 24.04 LTS. Setup Apache Tomcat 10 with OpenJDK 21, systemd service, web manager, and UFW firewall.
- Prerequisites and Supported Releases
- Step 1: Updating System Packages and Installing OpenJDK 21
- Step 2: Creating a Dedicated Tomcat System User and Group
Apache Tomcat is an open-source, enterprise-grade implementation of the Jakarta Servlet, Jakarta Pages (JSP), Jakarta Expression Language, and Jakarta WebSocket specifications. Backed by the Apache Software Foundation, Tomcat functions as a lightweight, lightning-fast Java application server powering mission-critical web applications, Spring Boot WAR packages, and enterprise microservices across the global software industry.
Deploying Tomcat on Ubuntu 24.04 LTS pairs an enterprise Linux server platform with the modern Jakarta EE 10 specification, delivering maximum security, asynchronous request processing, and seamless Java runtime optimization. Learning how to install tomcat on ubuntu 24.04 gives systems engineers and Java developers a dependable, production-hardened servlet container capable of hosting multi-tenant web applications.
In this comprehensive step-by-step tutorial, we demonstrate how to install Apache Tomcat 10 on Ubuntu 24.04 LTS (Noble Numbat). We cover installing OpenJDK 21, creating a dedicated unprivileged tomcat system user, downloading and verifying the latest Tomcat 10 distribution tarball into /opt/tomcat, configuring a robust systemd service unit, setting up administrative users in tomcat-users.xml, unlocking the Web Application Manager interface, and configuring UFW firewall rules.
Install and configure Apache Tomcat 10 on Ubuntu 24.04 LTS with OpenJDK 21, systemd daemon management, administrative web manager users, and secure firewall configuration.
Prerequisites and Supported Releases
This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat). The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.
Before proceeding, ensure you have the following requirements satisfied:
- A server or virtual machine running
Ubuntu 24.04 LTS. - A non-root user account configured with administrative
sudoprivileges. - At least
2 GB of RAM(4 GB recommended for enterprise Java servlets and Spring Boot WAR deployments). - Open port
8080available for HTTP traffic.
Step 1: Updating System Packages and Installing OpenJDK 21
Apache Tomcat 10 requires a Java Development Kit (JDK 17 or JDK 21 LTS) to compile servlets and execute compiled bytecode. Ubuntu 24.04 provides OpenJDK 21 as its default long-term support Java platform.
Update your local package lists and install default-jdk using APT.
Verify that the Java compiler (javac) and runtime (java) are properly configured on your system path.
# Update APT package repositories
sudo apt update && sudo apt upgrade -y
# Install OpenJDK 21 Java Development Kit
sudo apt install -y default-jdk curl wget
# Verify Java runtime and compiler versions
java -version
javac -version
Step 2: Creating a Dedicated Tomcat System User and Group
For security best practices, never execute the Tomcat server daemon under the root user account. Running Tomcat with administrative privileges risks exposing your entire server filesystem if a vulnerability exists in a deployed web application.
Create a dedicated system group named tomcat.
Create a dedicated system user named tomcat belonging to the tomcat group, assign their home directory to /opt/tomcat, and disable interactive shell login using /bin/false.
# Create tomcat group
sudo groupadd tomcat
# Create tomcat system user with /opt/tomcat home
sudo useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat
Step 3: Downloading and Extracting Apache Tomcat 10
Download the latest stable release tarball of Apache Tomcat 10 from the official Apache distribution mirror into your /tmp directory.
Create the destination directory at /opt/tomcat and extract the downloaded archive into it.
Strip the top-level directory during extraction so that the Tomcat files reside directly inside /opt/tomcat.
# Download Tomcat 10 binary tarball
cd /tmp
wget https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.34/bin/apache-tomcat-10.1.34.tar.gz -O tomcat10.tar.gz
# Create /opt/tomcat directory and extract archive
sudo mkdir -p /opt/tomcat
sudo tar -xzf tomcat10.tar.gz -C /opt/tomcat --strip-components=1
# Clean up downloaded archive
rm -f /tmp/tomcat10.tar.gz
Step 4: Configuring Directory Ownership and Permissions
Configure strict Linux filesystem permissions to protect the Tomcat installation from unauthorized tampering.
Grant the tomcat group read access to the conf/ directory, while restricting execute access to the configuration files.
Grant the tomcat user ownership of the webapps/, work/, temp/, and logs/ directories so that servlets can write session files and deploy WAR archives.
Make all scripts inside the bin/ directory executable.
# Change into /opt/tomcat directory
cd /opt/tomcat
# Set group ownership
sudo chgrp -R tomcat /opt/tomcat
# Grant read permissions to conf directory
sudo chmod -R g+r conf
sudo chmod g+x conf
# Assign ownership to tomcat user for runtime directories
sudo chown -R tomcat webapps/ work/ temp/ logs/
# Make scripts executable
sudo chmod +x bin/*.sh
Step 5: Creating the Systemd Service Unit for Tomcat
To manage Tomcat as a background service that automatically restarts on boot, configure a systemd service unit file.
First, find your system's exact Java home path using readlink -f $(which java).
Create the service file at /etc/systemd/system/tomcat.service.
Define the JAVA_HOME, CATALINA_HOME, memory heap arguments (-Xms512M -Xmx1024M), and execution commands.
# Verify Java installation path
readlink -f $(which java) | sed 's:/bin/java::'
# Create systemd service unit
sudo bash -c 'cat <<EOF > /etc/systemd/system/tomcat.service
[Unit]
Description=Apache Tomcat 10 Web Application Container
After=network.target
[Service]
Type=forking
User=tomcat
Group=tomcat
Environment="JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64"
Environment="JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom"
Environment="CATALINA_BASE=/opt/tomcat"
Environment="CATALINA_HOME=/opt/tomcat"
Environment="CATALINA_PID=/opt/tomcat/temp/tomcat.pid"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseG1GC"
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
RestartSec=10
Restart=always
[Install]
WantedBy=multi-user.target
EOF'
# Reload systemd, enable and start Tomcat
sudo systemctl daemon-reload
sudo systemctl enable --now tomcat
sudo systemctl status tomcat --no-pager
Step 6: Configuring UFW Firewall for Tomcat Port 8080
By default, Apache Tomcat listens for incoming HTTP web requests on TCP port 8080.
If Ubuntu's Uncomplicated Firewall (UFW) is active, you must permit traffic on port 8080.
Allow incoming traffic on port 8080 and verify active firewall rules.
# Allow incoming traffic on port 8080
sudo ufw allow 8080/tcp comment 'Apache Tomcat'
# Verify firewall status
sudo ufw status numbered
Step 7: Configuring Web Management Users in tomcat-users.xml
Tomcat includes two powerful administrative web interfaces: the Web Application Manager (/manager/html) for deploying WAR packages, and the Host Manager (/host-manager/html) for configuring virtual hosts.
To access these interfaces, you must define administrative users and roles in /opt/tomcat/conf/tomcat-users.xml.
Open the file with administrative privileges and declare roles for manager-gui and admin-gui.
Assign a strong, randomized password to the administrative account.
# Edit /opt/tomcat/conf/tomcat-users.xml before the </tomcat-users> tag:
# sudo nano /opt/tomcat/conf/tomcat-users.xml
# Add user block:
# <role rolename="manager-gui"/>
# <role rolename="admin-gui"/>
# <user username="tomcatadmin" password="StrongTomcatPass123!" roles="manager-gui,admin-gui"/>
Step 8: Unlocking Web Manager for Remote IP Addresses and Testing
By default, Tomcat restricts access to the Manager and Host Manager apps strictly to the local machine (localhost / 127.0.0.1).
If accessing your Ubuntu server remotely, you must comment out or adjust the RemoteAddrValve restriction in /opt/tomcat/webapps/manager/META-INF/context.xml and /opt/tomcat/webapps/host-manager/META-INF/context.xml.
Restart the Tomcat service to apply the configuration changes.
Open your browser and navigate to http://:8080/manager/html, entering your newly created credentials to access the deployment dashboard.
# Comment out RemoteAddrValve in Manager context.xml
sudo sed -i '/<Valve className="org.apache.catalina.valves.RemoteAddrValve"/s/^/<!-- /' /opt/tomcat/webapps/manager/META-INF/context.xml
sudo sed -i '/allow="127/s/$/ -->/' /opt/tomcat/webapps/manager/META-INF/context.xml
# Comment out RemoteAddrValve in Host-Manager context.xml
sudo sed -i '/<Valve className="org.apache.catalina.valves.RemoteAddrValve"/s/^/<!-- /' /opt/tomcat/webapps/host-manager/META-INF/context.xml
sudo sed -i '/allow="127/s/$/ -->/' /opt/tomcat/webapps/host-manager/META-INF/context.xml
# Restart Tomcat to apply changes
sudo systemctl restart tomcat
Troubleshooting and Common Errors
When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:
Tomcat service fails to start with 'JAVA_HOME is not set' error
Resolution: Verify the JAVA_HOME parameter in /etc/systemd/system/tomcat.service. Confirm the actual path using ls -ld /usr/lib/jvm/java-21-openjdk-amd64. Reload systemd daemon after making corrections.
Access Denied (403 Forbidden) when accessing /manager/html
Resolution: Ensure that you adjusted the RemoteAddrValve in /opt/tomcat/webapps/manager/META-INF/context.xml and restarted Tomcat. Verify that your username and password in conf/tomcat-users.xml possess the manager-gui role.
Port 8080 is already in use by another daemon
Resolution: Find conflicting processes using sudo ss -tulpn | grep 8080. You can change Tomcat's listening port to 8088 or another port in /opt/tomcat/conf/server.xml.
Security Best Practices and Hardening
Never run the Apache Tomcat server daemon under the root user account; use the dedicated unprivileged 'tomcat' system user.
In production environments, never expose port 8080 directly to the internet; use an Nginx or Apache reverse proxy with Let's Encrypt TLS encryption.
Assign strong, complex passwords in tomcat-users.xml to prevent brute-force exploitation of the Web Application Manager.
Remove or restrict access to default sample applications inside /opt/tomcat/webapps/docs and /opt/tomcat/webapps/examples.
Related Ubuntu Tutorials and Documentation
Deepen your Linux system administration skills with our related production-tested guides:
Authoritative References and Official Documentation

The Linux Command Line, 2nd Edition: A Complete Introduction
Frequently Asked Questions
Quick answers to common questions and configurations
.war file directly into /opt/tomcat/webapps/ (Tomcat will auto-extract it), or upload it through the graphical Web Application Manager at http://server_ip:8080/manager/html./etc/systemd/system/tomcat.service and adjust the CATALINA_OPTS parameter (e.g., -Xms1024M -Xmx2048M). Run sudo systemctl daemon-reload && sudo systemctl restart tomcat.Editorial Disclosure: Website Vidya is supported by our readers. When you purchase hosting, tools, or software through our verified partner links, we may earn an affiliate commission at no extra cost to you. We only recommend solutions we trust and rigorously verify.
Rajesh Ray
I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.
Most Read Guides
TrendingUbuntu Server Not Booting? 10 Simple Steps to Fix It Fast
How to Create a 3D Button in HTML and CSS: Easy Steps
How to Install Python and Pip on Ubuntu 24.04 LTS
How to Install Nginx on Ubuntu 24.04
How to Install Python on Ubuntu 24.04 LTS
Related Technical Guides
Tested runbooks, server administration walkthroughs, and troubleshooting guides


Join the Conversation & Perspective
Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.
No comments on this guide yet. Be the first to share your thoughts or ask a question!