How to Install Apache Tomcat 10 on Ubuntu 21

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
"The best Linux newsletter on the web"

Apache Tomcat is an open-source Java servlet and Java Server Page container. Developers build and deploy dynamic java-based applications using Apache Tomcat. Java servlets are small java programs defining how a server handles requests and responses. Developers write the servlets while Tomcat handles all the backend and routing. As it is an opensource tool, Apache Tomcat is contributed by developers all over the world.

Apache Tomcat is an open-source Java HTTP web server developed by the Apache Software Foundation. Tomcat helps to deploy the Java Servlet and the JavaServer Pages and serves them like an HTTP web server.

In this guide we will install Apache Tomcat 10 on Ubuntu 21.

Install JDK Ubuntu linux system.

apt update
apt install default-jdk

Check java version with the following command:

java -version

Download Apache Tomcat archive.

apt install wget

Extract the tar file.

tar -xvzf apache-tomcat-10.0.12.tar.gz

Move extracted file to /usr/share directory.

mv apache-tomcat-10.0.12/ /usr/share/apache-tomcat

Create apache tomcat user because we will use this user. Also give permissions to user tomcat.

useradd -M -d /usr/share/apache-tomcat tomcat
chown -R tomcat /usr/share/apache-tomcat

Allow access to Apache Tomcat UI from your IP.

nano /usr/share/apache-tomcat/webapps/manager/META-INF/context.xml

Add your IP in this file.

Do the same with the following file:

nano /usr/share/apache-tomcat/webapps/host-manager/META-INF/context.xml

Save and quit both files after adding IP.

Now secure access to admin UI. Edit the following file:

nano /usr/share/apache-tomcat/conf/tomcat-users.xml

Add following lines before context </tomcat-users>:

<!-- manager section user role -->
<role rolename="manager-gui" />
<user username="manager" password="Passw0rd" roles="manager-gui" />

<!-- admin section user role -->
<role rolename="admin-gui" />
<user username="admin" password="Strong123" roles="manager-gui,admin-gui" />

save and exit the file.

Create systemd unit for tomcat to start / stop and restart service.

nano /etc/systemd/system/tomcat.service

Paste following lines:






ExecStart=/usr/share/apache-tomcat/bin/ start
ExecStop=/usr/share/apache-tomcat/bin/ stop


Save and Exit.

Reload system daemon and start Tomcat Service.

systemctl daemon-reload
systemctl restart tomcat
systemctl enable tomcat
systemctl status tomcat
ufw allow 8080

Now open your web browser and type https://yourIP:8080. You will see the default tomcat page. You can use it as per your need.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
"The best Linux newsletter on the web"
Unix/Linux Guru and FOSS supporter


Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook