Install Apache Tomcat on Ubuntu
Installation

Install Apache Tomcat on Ubuntu

Sagar Sharma
Sagar Sharma

Table of Contents

Want to deploy a java application? Apache Tomcat is one of the best ways to do so.

So what do you expect from one of the most popular application servers? Clustering, session replication, and JMX-based server monitoring are a few of the many.

And in this tutorial, I will walk you through the following:

  • How to install Apache Tomcat
  • How to enable web application manager for Tomcat

So let's start with the installation.

How to install Apache Tomcat on Ubuntu

Before jumping to the installation, it is necessary for you to have java installed on your system.

To install java on ubuntu, you can use the following command:

sudo apt install openjdk-11-jdk

To confirm the installation, check the installed version of java:

java -version
check installed version of java on ubuntu

Once you are done installing java, now, you can use the following command to install Tomcat:

sudo apt install tomcat9 tomcat9-admin

Tomcat listens on port number 8080, which you can confirm using the ss command:

ss -ltn
tomcat listening to port no 8080

Also, if you are using the UFW firewall, you will have to allow port no 8080:

sudo ufw allow 8080/tcp

That's it! You have it installed.

You can test the Tomcat install by appending port no 8080 to your IP address in your browser:

IP_address:8080
check the tomcat install on ubuntu

And if you get a similar result, you have installed Tomcat without any issues.

How to enable web application manager for Tomcat

To enable the web application manager, you will have to create a user and password.

And to do that, you will have to make changes in the tomcat-users.xml file:

sudo nano /etc/tomcat9/tomcat-users.xml

Remove everything from the file. And enter the following:

<?xml version="1.0" encoding="UTF-8"?>
<tomcat-users>
  <role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <role rolename="manager-jmx"/>
  <role rolename="manager-status"/>
  <role rolename="admin-gui"/>
  <role rolename="admin-script"/>
  <user username="admin" password="Strong_password" roles="manager-gui, manager-sc>
</tomcat-users>
configure web application manager for Tomcat in ubuntu

Here, I used sagar as username and used Password@123 as my password.

Save changes and exit from the nano text editor.

To take effect from the changes you made in the file, restart the service using the following command:

sudo systemctl restart tomcat9

And now, you can access the web application manager by entering the following into the address bar:

http://IP_address:8080/manager/html
use tomcat web application manager in ubuntu

Pretty easy. Isn't it?

Did you know that you can live patch Ubuntu?

Live patching is where you can apply patches to a kernel even without rebooting your system.

Want to learn how? We have a detailed guide for that:

How to Enable Livepatching on Ubuntu Server
Tired of rebooting your Ubuntu server after every security upgrade? You may enable live kernel patching and forget about reboots altogether.

I hope you will find this guide helpful.

And if you face any errors while executing shown steps, let me know in the comments.



Sagar Sharma

Sagar Sharma

A software engineer who loves to tinker with hardware till it gets crashed. While reviving my crashed system, you can find me reading literature, manga, or watering my plants.