How to install Apache Tomcat 10 on Ubuntu 22.04 LTS

Learn the steps and commands to install the latest version of Apache Tomcat on Ubuntu 22.04 LTS Jammy JellyFish Linux to test various Java-based applications…

Apache Tomcat is an open-source web server that allows you to run web applications written in Java. Tomcat is developed and maintained by a free community of developers and our Apache license is published as open-source software.

Well, Tomcat is significantly different from the Apache web server, it was developed to primarily focus on Web applications. Tomcat does not understand URLs as a file specification, but as a notification of a user action. This is comparable to event-driven programming in classic GUI programming: a click on a button generates an event that the window manager reports to the program. Calling up a URL is analogous, be it in the form of a link or a form called.

We can set up Tomcat on almost all popular operating systems because the key requirement of it is Java 8 or higher depending upon which version you are planning to use.

Steps to install Apache Tomcat on Ubuntu 22.04 Linux

1. Install OpenJDK- Java

As we know the key requirement to install Tomcat is Java, thus first we set up an open-source Java Development kit on Ubuntu 22.04 LTS using the terminal.

Before moving further, run the system update command once.

sudo apt update

The OpenJDK packages are available in the default base repository of Ubuntu 22.04 LTS Jammy, thus use the given command to install it.  The java version supported is 8 or above. Here we are getting Java 11.

sudo apt install default-jdk

To check and confirm, that Java has been installed successfully, see its version…

java -version


2. Download Apache Tomcat

You can get the latest version directly from the official webpage of Tomcat. If you are using a GUI system then can download it by simply clicking on the Zip or Tar file. However, those who are accessing a  remote server with CLI via SSH can use the wget. Simply, right-click on the Tart.gz file and copy the link address. After that type wget on your terminal and paste the link.

wget paste-link

Download Apache Tomcat on Ubuntu 22.04


3. Install Apache Tomcat on Ubuntu 22.04

Extract the downloaded file to /opt directory so that we won’t delete it accidentally.

1. Create a directory under /opt to extract files.

sudo mkdir -p /opt/tomcat

2. Now, extract the downloaded Tomcat Tar file into the created directory.

sudo tar xzvf apache-tomcat-*tar.gz -C /opt/tomcat --strip-components=1

Create a dedicated user

To ensure the security of the system while testing various web applications, let’s create a non-root user that has only access to the created /opt/tomcat folder.

sudo groupadd tomcat
sudo useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat


4. Assigning Tomcat user permissions

Well, we already have set up the files that require using this open-source web application server, now let’s assign the permission of the folder to the user we have created above for it.

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


5. Create a Systemd service file

By default, we won’t have a Systemd unit file for Tomcat to run it in the background and to easily stop, start and enable its services. Thus, we create one, so that we could manage it without any issues.

Create Systemd unit file

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

Paste the following block of code in it-

Description=Tomcat webs servlet container



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



To save the press Ctrl+X, type –Y, and hit the Enter Key.

Note: In the above-given code for creating a systemd file, we have to mention the path of Java. However, the given one in the above code is the default path, still, to confirm the same you can run the below command:

sudo update-java-alternatives -l


6. Enable and start Tomcat service on Ubuntu 22.04

Finally, we have plugged in all the necessary things to start the Tomcat service in the background on Ubuntu 22.04 LTS Jammy. Let’s enable and run the same.

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

To confirm everything is working normally, check the status of service:

systemctl status tomcat --no-pager -l


7. Add Roles and Admin username and password

This step is important, without performing it we will get an error: “403 Access Denied on Tomcat 10/9/8 error” as we click on “Server Status“, “Manager App” and “Host Manager” links on the Apache Tomcat Web interface.

Edit user configuration file.

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

At the end just before </tomcat-users> tag copy and paste the following lines.
Note– Change the username and password values with whatever you want to set for your Tomcat.

<role rolename="admin"/>
<role rolename="admin-gui"/>
<role rolename="manager"/>
<role rolename="manager-gui"/>

<user username="h2s" password="pwd" roles="admin,admin-gui,manager,manager-gui"/>

Save the file and exit- Ctrl+X, type- Y, and hit the Enter key.

Add Roles and Admin username and password Apache Tomcat


8. Enable Tomcat and Host Manager Remote access

By default, you won’t be able to access your installed Tomcat Manager sections (web interface) outside the local system. For that, we have to enable it by editing individually the context.xml file available for Tomcat Manager and Host Manager.

For Tomcat Manager’s remote access:

Edit the Context file  

sudo nano /opt/tomcat/webapps/manager/META-INF/context.xml

In the file, scroll and go to the end and comment out the following block of text-

<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />

Just add <!-- at the beginning and --> in the end, after that, this will look something like this-

<!-- <Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> -->

Save the file and exit- Ctrl+X, type- Y, and hit the Enter key.

To get an idea see the below-given screenshot:



For Host manager remote access:

sudo nano /opt/tomcat/webapps/host-manager/META-INF/context.xml

Just like above, also add <!-- at the beginning and --> at the end of the text given below in the file, after that, this will look like something this-

<!-- <Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> -->

Save the file and exit.

Note-: By commenting out, the Tomcat will not be able to read this and let the user access the Manager backend using a remote PC.

Restart Tomcat service-

sudo systemctl restart tomcat


9. Open port 8080 in Ubuntu 22.04 Firewall

The service to access the web interface via browser is available on port 8080 and to access the same remotely using any other system, we have to allow its outgoing connection in the firewall.

sudo ufw allow 8080


10. Access the Tomcat Web interface

Open any browser on the local or remote system and point it to the IP address or domain of the server where you have installed the Apache Tomcat.

For example:


Access Tomcat Web interface Access Tomcat Web interface install Ubuntu 22.04 LTS

11. Web Application Manager

Web Application Manager

12. Virtual Host Manager

Virtual Host Manager

In this way, we can deploy the Apache Tomcat on Ubuntu 22.04 LTS without any error. In case you are facing any problems while performing the above tutorial, the comment section is all yours!!


Other Articles:

Install Apache Tomcat on AlmaLinux 8
How to install Oracle Java 8 64-bit Ubuntu 22.04 | 20.04 LTS
How to increase Swap Space in Ubuntu 22.04…
How to install Opera Browser on Ubuntu 22.04…


1 thought on “How to install Apache Tomcat 10 on Ubuntu 22.04 LTS”

  1. Thank you very much man!! This worked out great for me after I had spent like an hour trying to do it with other tutorials.
    Keep up the good work.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.