Menu
User

DropVPS Team

Writer: Cooper Reagan

How to Install Apache Tomcat on Ubuntu 25.04

How to Install Apache Tomcat on Ubuntu 25.04

Publication Date

09/22/2025

Category

Articles

Reading Time

2 Min

Table of Contents

Apache Tomcat is a widely used open-source Java servlet container that powers many Java web applications. It is lightweight, secure, and well-suited for running JavaServer Pages (JSP) and servlets.

Step 1: Update System Packages

Always make sure your system is updated before installing new software:

sudo apt update && sudo apt upgrade -y

Step 2: Install Java

Tomcat requires Java to run. Install OpenJDK with:

sudo apt install -y openjdk-17-jdk
java -version

Step 3: Create a Tomcat User

For security reasons, it is recommended to run Tomcat under a dedicated user:

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

Step 4: Download Apache Tomcat

Visit the official Tomcat website and download the latest version (replace the version number if needed):

cd /tmp
wget https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.24/bin/apache-tomcat-10.1.24.tar.gz

Extract it into /opt/tomcat:

sudo tar -xvzf apache-tomcat-10.1.24.tar.gz -C /opt/tomcat
sudo ln -s /opt/tomcat/apache-tomcat-10.1.24 /opt/tomcat/latest
sudo chown -R tomcat:tomcat /opt/tomcat

Step 5: Create a Systemd Service File

Set up Tomcat as a service so it can run in the background:

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

Paste the following:

[Unit]
Description=Apache Tomcat Web Application Container
After=network.target

[Service]
Type=forking

User=tomcat
Group=tomcat

Environment="JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64"
Environment="CATALINA_PID=/opt/tomcat/latest/temp/tomcat.pid"
Environment="CATALINA_HOME=/opt/tomcat/latest"
Environment="CATALINA_BASE=/opt/tomcat/latest"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"
Environment="JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom"

ExecStart=/opt/tomcat/latest/bin/startup.sh
ExecStop=/opt/tomcat/latest/bin/shutdown.sh

[Install]
WantedBy=multi-user.target

Save and exit, then reload systemd:

sudo systemctl daemon-reload
sudo systemctl enable tomcat
sudo systemctl start tomcat

Step 6: Access Apache Tomcat

Check if the service is running:

sudo systemctl status tomcat

Then open your browser and go to:

http://your_server_ip:8080

You should see the Tomcat default welcome page.

Apache Tomcat is now installed and running on Ubuntu 25.04. Your server is ready to deploy Java applications and manage them through the Tomcat environment.

Linux VPS
U
Loading...

Related Posts