How to setup Apache Tomcat on Linux

Apache Tomcat or just Tomcat is a free open source web server developed by Apache Software Foundation for the implementation of Java Servlet, JavaServer Pages, Java Expression Language, and Web Socket technologies. It provides a “pure Java” http server.

Apache Tomcat provides a default HTTP connector on port 8080 which allows it to be used as a web server such as Apache, for your Java applications.

This article will show you how to fully configure your server. Apache Tomcat on your Linux machine.

Note We have tested the installation instructions and methods on Ubuntu 20.04 and Debian 10.7 server.


To complete the installation process described in this guide, you will need:

  1. Fully updated Linux server
  2. Sudo or root permissions

Installation Apache Tomcat

Let’s start by installing Tomcat on our server.

Installing Java JDK

Before installation Apache Tomcat, we need to make sure that a working version of Java is installed on our server.

In our example, we will be using the Amazon Corretto JDK.

Start by updating your system and install java-common, wget and curl how:

                      sudo apt-get update
sudo apt-get install java-common curl wget  -y

Then launch your browser and navigate to the Amazon Corretto download page as indicated in the resource below:


Find the package for your Linux system and copy the download link.

After copying the download link, open a terminal and enter the command below:


The above command will download the Corretto JDK on your system for installation.

Once the download is complete, enter the command below to install the JDK package.

                      sudo dpkg -i amazon-corretto-11-x64-linux-jdk.deb

The above command will use the downloaded Debian package to install the JDK.

To make sure the installation is complete and you have the JDK installed, enter the command:

                      java --version

Running this command should print the Java version and JDK provider. Below is an example of the output:

                      openjdk 11.0.12 2021-07-20 LTS
OpenJDK Runtime Environment Corretto- (build 11.0.12+7-LTS)
OpenJDK 64-Bit Server VM Corretto- (build 11.0.12+7-LTS, mixed mode)

Tomcat user setup

For security reasons, it is best to have a user account to start the services Apache Tomcat. Avoid using root user to start tomcat server.

Let’s start by creating a tomcat user with default home directory and shell set to false.

                      sudo useradd -m -U -d /home/tomcat -s $(which false) tomcat

To ensure that the tomcat user exists with the correct information, enter the / etc / passwd file as:

                      cat /etc/passwd | grep tomcat

Below is an example of the output:


Installing Tomcat 10

The next step is to install the Tomcat binary on our system. At the time of this writing Apache Tomcat 10 is not available in the official repositories for major Linux distributions.

Launch your browser and go to the download page Apache Tomcat 10.

Select tar or zip archive and copy download link.

How to setup Apache Tomcat on Linux

Open a terminal and navigate to the Tomcat user home directory that we created in the previous step.

                      cd /home/tomcat

Then use wget or curlto download the tomcat archive as:

                      sudo wget

The last step is to unzip the files and save them in the tomcat home directory. You can use the command:

                      sudo tar xvf apache-tomcat-10.0.10.tar.gz -C . --strip-components=1

The next step is to use the chown command to set the correct permissions for the apache tomcat files.

                      sudo chown -R tomcat: Tomcat.
sudo chmod -R u+x ./bin/

How to set up a user Apache Tomcat on Linux

To customize users Apache Tomcat, we need to edit the tomcat-users.xml file in the conf directory.

Edit the file and add user details as shown in the example below:

                      sudo vim /home/tomcat/conf/tomcat-users.xml

Add lines like

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

In the above configuration example, the tomcat username can only access the Tomcat manager, and the administrator username can access both the manager and the admin interface.

Make sure you add the username configuration shown above between the following blocks


Finally, save the file and close the editor.

To start the server Apache Tomcat, enter the command:

                      sudo /home/tomcat/bin/

How to access Tomcat

After starting the Tomcat server, it will run on port 8080 by default and you can access the interface by going to

If the tomcat server is running, you should see the default tomcat page:

How to setup Apache Tomcat on Linux
If you’d like to learn about the different ways to start and stop the apache tomcat service, check out our article on this topic.


This article shows you how to install and configure the server Apache Tomcat on Linux. Check out our other Tomcat guides to learn more about securing and administering your Tomcat server.

Related Posts