How To Install Apache Tomcat on Ubuntu 20.04 LTS

How To Install Apache Tomcat On Ubuntu 20.04 LTS

On this tutorial we will discuss how to install Apache Tomcat 9.0.41 on Linux Ubuntu 20.04 LTS operating system.


Apache Tomcat is an open-source of Java technology implementation. Tomcat is one of the most popular choices for building Java-based websites and applications. There are several Java technology namely : Java Servlet, JavaServer Pages, Java Expression Language and WebSocket technologies. On this tutorial we will discuss how to install the last stabel version of Apache Tomcat on Linux Ubuntu 20.04 LTS operating system. The last stable of Apache Tomcat is version 9.0.41 which was released on 8, 2020.

The Apache Tomcat installation wil be consist of several steps, namely :


Before the Apache Tomcat installation process begins, we must prepare several requirements, namely:

  1. having root or an ordinary user with sudo privilege
  2. Java installed on the system, Apache Tomcat requires Java runtime to run properly on the system. We will query the java version installed to make sure if Java was installed by submitting command line : java –version.
ramans@diginet-app02:~$ java -version
 openjdk version "" 2020-11-04
 OpenJDK Runtime Environment (build
 OpenJDK 64-Bit Server VM (build, mixed mode, sharing)
Java version

If our system has no Java installed yet, just install it fires. For Java installation on Ubuntu 20.04 LTS can be found on this article.

Apache Tomcat installation on Ubuntu 20.04 LTS

On this tutorial, we will use the latest stable Apache Tomcat, version 9.0.41 which has been available official Apache Tomcat download page.

Update System

Before Apache Tomcat installation is starting, we will update our Ubuntu 20l.04 LTS system first, by submitting command line : sudo apt update.

ramans@diginet-app02:~$ sudo apt update
[sudo] password for ramans: 
Hit:1 focal InRelease     
Get:2 focal-security InRelease [109 kB]
Get:3 focal-updates InRelease [114 kB]
update system
update Ubuntu System

Creating System User

We need a non root user to run the Tomcat service for security and management purpose, called as tomcat. We will create a new system user with /opt/tomcat as his default directory.

ramans@diginet-app02:~$ sudo useradd -m -U -d /opt/tomcat -s /bin/false tomcat
 [sudo] password for ramans: 

Download Apache Tomcat distribution file

On this section we will download Apache Tomcat 9.0.41, extract it and creating systemd service. We will download the latest Apache Tomcat source located which is located at the by using wget command line.

ramans@diginet-app02:~$ sudo mkdir /opt/tomcat
ramans@diginet-app02:~$ wget
 --2021-01-09 07:05:34--
 Resolving (…, 2a01:4f8:10a:201a::2
 Connecting to (||:443… connected.
 HTTP request sent, awaiting response… 200 OK
 Length: 11442169 (11M) [application/x-gzip]
 Saving to: ‘apache-tomcat-9.0.41.tar.gz’
 apache-tomcat-9.0.41.tar.gz  100%[============================================>]  10.91M   765KB/s    in 19s     
 2021-01-09 07:05:54 (600 KB/s) - ‘apache-tomcat-9.0.41.tar.gz’ saved [11442169/11442169]
Download Apache 9.0.41 binary source
Download Apache 9.0.41 binary source

Extract Binary File

On this step, we will extract the source file to /opt/tomcat directory.

ramans@diginet-app02:~$ sudo tar xzvf apache-tomcat-9.0.41.tar.gz -C /opt/tomcat --strip-components=1
 [sudo] password for ramans: 
Extract Apache Tomcat source files
Extract Apache Tomcat source files

Setup Permission

After Tomcat binary files are extracted then we have to set the right permission on their files under tomcat user.

sudo chgrp -R tomcat /opt/tomcat
sudo chmod -R g+r conf
sudo chmod g+x conf
sudo chown -R tomcat webapps/ work/ temp/ logs/
directory tomcat setup permission
Apache Tomcat setup permission

Creating Apache Tomcat Service

On this section, we will create Apache Tomcat systemd file and activate it as a service. Create a file under /etc/systemd/system directory and name it as tomcat.service. Verify and make sure the JAVA_HOME with the path of our Java installation. The conten of its file is as follow :

ramans@diginet-app02:~$ cd /etc/systemd/system
ramans@diginet-app0[2:/etc/systemd/system$ sudo vi /etc/systemd/system/tomcat.service
sudo] password for ramans: 
 Description=Apache Tomcat Web Application Container

 Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
Apache Tomcat 9.0.41
tomcat.service file

After tomca.service file was created, then we reload the service on our sever system, and start the tomcat service and verify if the service is running properly.

ramans@diginet-app02:/etc/systemd/system$ sudo systemctl daemon-reload
 ramans@diginet-app02:/etc/systemd/system$ sudo systemctl start tomcat
 ramans@diginet-app02:/etc/systemd/system$ sudo systemctl status tomcat
 ● tomcat.service - Apache Tomcat Web Application Container
     Loaded: loaded (/etc/systemd/system/tomcat.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2021-01-09 09:28:53 PST; 1min 10s ago
     Process: 68356 ExecStart=/opt/tomcat/bin/ (code=exited, status=0/SUCCESS)
    Main PID: 68363 (java)
      Tasks: 30 (limit: 9451)
      Memory: 138.8M
      CGroup: /system.slice/tomcat.service
              └─68363 /usr/lib/jvm/java-1.11.0-openjdk-amd64/bin/java -Djava.util.logging.config.file=/opt/tomca>
 Jan 09 09:28:53 diginet-app02 systemd[1]: Starting Apache Tomcat Web Application Container…
 Jan 09 09:28:53 diginet-app02[68356]: Tomcat started.
 Jan 09 09:28:53 diginet-app02 systemd[1]: Started Apache Tomcat Web Application Container.
 ramans@diginet-app02:/etc/systemd/system$ sudo vi opt/tomcat/conf/tomcat-users.xml
 ramans@diginet-app02:/etc/systemd/system$ sudo vi /opt/tomcat/conf/tomcat-users.xml
Apache Tomcat service has been started
Apache Tomcat service

Configuring Apache Tomcat

After the Apache Tomcat service is running properly, then we need to configure it as suitable with our application need. For doing this, we need to access the Apache Tomcat web portal which is by default binding on port 8080. To access and use the Apache Tomcat web app manager, we need to login to the server. To setup username and password we have to edit the tomcat-users.xml file.

ramans@diginet-app02:/opt/tomcat$ sudo vi /opt/tomcat/conf/tomcat-users.xml
 [sudo] password for ramans: 

Then we update the file with these entries :


Configuring Firewall

If our server is located inside a firewall system, then we have to allow traffic from any source to port 8080 of the our Tomcat Server. By default Tomcat is running on port 8080, So we need to open port 8080 to allow connections.

Allow Apache Tomcat Connection
Allow Apache Tomcat Connection

Accessing Apache Tomcat

This is the last section on how to install Apache Tomcat on Ubuntu 20.04 LTS article. On this section we will test the Apache Tomcat server. By using browser we can open external IP address followed by port 8080.

On this case we will use

Apache Tomcat Web App
Apache Tomcat Web App


So far, we have installed Apache Tomcat 9.0.41. on Ubuntu 20.04 LTS operating system successfully. For further exploration about Apache Tomcat, just go to Apache Tomcat official web. Have a nice day… stay safe, stay at home.

Share this article via :

Leave a Reply

Your email address will not be published. Required fields are marked *