What is Apache Tomcat?
Tomcat is a Servlet Container. It comprises a Thread pool and a ClassLoader Hierarchy. Tomcat scans a Webapp first whenever it is ready to be deployed. After that, it reads the descriptor of Webapp deployment and then it takes the decision of whether these Servlets are going to be available or deployed.
In this article, you are going to learn how you can install Apache Tomcat Server on Ubuntu 20.04. It’s better to know some major reasons why you should use it, before moving ahead.
Reasons you should use Tomcat:
- Tomcat is Open-source.
- It is Lightweight.
- It provides an extra security level.
- Also provides stability to your server.
- It is more flexible.
Now let’s move on to its Installation process on Ubuntu 20.04.
Note: To follow the installation, make sure that you are a ‘superuser’ or ‘root’ as the superuser provides unrestricted access to all the commands, files, resources, and directories.
Install Apache Tomcat Server on Ubuntu 20.04
Step 1: First of all, Open up the terminal by searching it manually in activities, or you can also press ‘CTRL+ALT+T’ to view the terminal window.
Step 2: Now update the package lists.
$ sudo apt-get update
Step 3: Search your repository for the Tomcat server package
$ sudo apt-cache search tomcat
The output will let you know the packages list.
Step 4: In this step, we are going to download all the dependencies and the admin package related to Tomcat Server 9.
$ sudo apt install tomcat9 tomcat9-admin
Enter ‘y’ to permit the process to continue.
Step 5: Output of the previous step shows that the Tomcat 9 is installed on your Ubuntu 20.04. To confirm its existence use the ‘ss’ command given below. It should show you the ‘8080’ port number for the Tomcat port.
$ ss -ltn
Step 6: Enable the Tomcat Server by writing-out the following command.
$ sudo systemctl enable tomcat9
Step 7: For allowing the traffic from the Tomcat Server port, write-out the following command.
$ sudo ufw allow from any to any port 8080 proto tcp
Use the given URL for the confirmation of this web application manager.
Tomcat Server is enabled and working as the pages states ‘it works’.
Step 8: You can also create users in Tomcat.
$ sudo nano /etc/tomcat9/tomcat-users.xml
Add the following lines in the opened script.
$<role rolename="admin-gui"/> <role rolename="manager-gui"/> <user username="tomcat" password="pass"roles="admin-gui,manager-gui"/>
Now, Save this ‘tpmcat-users.xml’ file and follow the next step.
Step 9: Restart your Tomcat Server.
$ sudo systemctl restart tomcat9
Enter the following URL for accessing the manager of Tomcat Web Server.
You should see this screen and now enter your credentials.
In this article, we have discussed Tomcat Server’s features and some of the reasons why you should use it. Furthermore, we have also shared its Installation method on Ubuntu 20.04 step by step.
TUTORIALS ON LINUX, PROGRAMMING & TECHNOLOGY