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:
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:
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:
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
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>
Here, I used
sagar as username and used
[email protected] 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:
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:
I hope you will find this guide helpful.
And if you face any errors while executing shown steps, let me know in the comments.