Tomcat is an open-source web server for Java-based web applications. It is used in development with Spring and JSP. In this guide, you will learn how to install and configure Tomcat version 9 on Ubuntu, Debian, or any of their derivatives.

Apache Tomcat is an open-source web server, allowing you to execute java code. It can execute Java-related technologies such as Java Servlet, JSP, Java Expression Language, WebSockets, etc. Being open-source, Tomcat is mainly developed and maintained by open community developers under the Apache software foundation.

So let’s how to install and configure Tomcat in Ubuntu or Debian and demonstrate a JSP program.


As Tomcat runs the Java code, so you have set up JDK (Java Development Kit) in your distribution first proceeding to the Tomcat installation.

To install JDK, execute the given command.

sudo apt-get install default-jdk

When installation completes, you can verify the JDK version.

java -version
Checking JDK version

Installing Tomcat 9 on Ubuntu / Debian

In order to install Tomcat, you need to get the tomcat.tar file from its official website. This bundle file contains all the binary and config files for the server. It can be downloaded from the link below.

Download Tomcat

You can also download it through the command-line.


After downloading the tomcat bundle file, you need to extract it.

tar -xvzf apache-tomcat-9.0.46.tar.gz

Now create a /tomcat directory in the /opt/ folder and move all the files from the extracted folder to the newly created folder.

sudo mkdir /opt/tomcat
sudo mv apache-tomcat-9.0.46/* /opt/tomcat/

Your folder should look like this.

tomcat server folder

In order to manage the Tomcat server, you need to create an admin and manager user. For this open the tomcat-users.xml file and add the user details.

This file can be found in the /conf folder.

sudo nano /opt/tomcat/conf/tomcat-users.xml

Add the following user configuration details, just before the </tomcat-users> closing tag and save the file (Ctrl+O to save).

<role rolename="manager-gui"/>
<user username="manager" password="anyPassword" roles="manager-gui"/>

<role rolename="admin-gui"/>
<user username="admin" password="anyPassword" roles="admin-gui, manager-gui"/>

Finally, you can start the server, for this navigate to the bin folder and execute the startup script.

To start & stop tomcat server
cd /opt/tomcat/bin/ && ./
running tomcat in ubuntu

Now you can view the tomcat server webpage in the broweser, simply head on to the http://localhost:8080

Tomcat in browser - localhost address

Similarly, you can stop the server by executing the


Watch Tomcat installation guide on YouTube

Additionally, You can also watch a step-by-step video guide on YouTube to get a better understanding of it.


So that is how you can install and configure the Apache Tomcat server in Ubuntu or Debian. Let me know what you think about it in the comments and subscribe to the LinuxH2O Youtube channel. Till then, keep enjoying Linux.