You can support us by downloading this article as PDF from the Link below. Download the guide as PDF

The objective of this guide is to help you get Apache Tomcat up and running on your Ubuntu 18.04 server (Bionic Beaver).  Apache Tomcat is an open source implementation of the Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies.

Apache Tomcat Requirements

  • – Tomcat 9.x requires Java SE 8 or later.
  • – Updated Ubuntu 18.04 OS
  • – A user with sudo privileges

Before we can start the installation of Apache Tomcat, we need to install and configure Java SE Development Kit 8 (JDK8).

Install Java JDK 8 on Ubuntu 18.04

For this guide, we will install Oracle Java JDK 8 using PPA repository available for Ubuntu 18.04. The PPA repository we’ll use is ppa:webupd8team/java which can be added to Ubuntu using the following command:

$ sudo add-apt-repository ppa:webupd8team/java
 Oracle Java (JDK) Installer (automatically downloads and installs Oracle JDK8). There are no actual Java files in this PPA.

Important -> Why Oracle Java 7 And 6 Installers No Longer Work:

Update: Oracle Java 9 has reached end of life:

The PPA supports Ubuntu 18.04, 17.10, 16.04, 14.04 and 12.04.

More info (and Ubuntu installation instructions):
- for Oracle Java 8:

Debian installation instructions:
- Oracle Java 8:

For Oracle Java 10, see a different PPA:
 More info:
Press [ENTER] to continue or Ctrl-c to cancel adding it.

Press <Enter> key to continue with the installation.

Then install Java JDK 8  using the command:

$ sudo apt install oracle-java8-set-default
Reading package lists... Done
Building dependency tree 
Reading state information... Done
The following additional packages will be installed:
gsfonts-x11 java-common libfontenc1 oracle-java8-installer x11-common
xfonts-encodings xfonts-utils
Suggested packages:
Do you want to continue? [Y/n] y

install java ubuntu 18.04 03 install java ubuntu 18.04 04

Note that you can also install Java Open JDK version 8 using official Ubuntu repositories, just execute:

$ sudo apt install openjdk-8-jdk

Confirm the version of Java installed:

$ java -version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)

If you want to change the default version of Java used in your system, use the command:

$ sudo update-alternatives --config java
There is 1 choice for the alternative java (providing /usr/bin/java).

Selection Path Priority Status
0 /usr/lib/jvm/java-8-oracle/jre/bin/java 1081 auto mode
* 1 /usr/lib/jvm/java-8-oracle/jre/bin/java 1081 manual mode

Press <enter> to keep the current choice[*], or type selection number: 0

Install Apache Tomcat 9 on Ubuntu 18.04

Now that we have Java Open JDK installed, we should be ready to start the installation of Apache Tomcat on Ubuntu 18.04. The installation process is as below:

Step 1: Download Apache Tomcat archive

Let’s download Apache tomcat 9 using wget:

$ sudo apt-get install wget
$ wget
$ wget

For Apache Tomcat 8, use:

$ wget
$ wget

Step 2: Extract tar archive and install Tomcat

# tar xvf apache-tomcat-9.0.8.tar.gz

Move extracted files to /usr

# mv apache-tomcat-9.0.8 /usr/share/

Create apache tomcat9 user

# useradd -M -d /usr/share/apache-tomcat-9.0.8/ tomcat9
# chown -R tomcat9 /usr/share/apache-tomcat-9.0.8/

Allow access to Apache Tomcat UI from trusted network/Ip:

Edit the files:


Modify allow line to add ip from which you want to access UI interface.

allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1|" />

Secure Access to admin/manager dashboard

We need to secure access to admin areas of tomcat UI, edit the file:


Add the following content before </tomcat-users>

<!-- manager section user role -->
<role rolename="manager-gui" />
<user username="manager" password="[email protected]" roles="manager-gui" />

<!-- admin section user role -->
<role rolename="admin-gui" />
<user username="admin" password="[email protected]" roles="manager-gui,admin-gui" />

Start Apache Tomcat service:

You can now manage apache tomcat service with the user account we added (tomcat9)

# su - tomcat9 -c /usr/share/apache-tomcat-9.0.8/bin/ start
Using CATALINA_BASE: /usr/share/apache-tomcat-9.0.8
Using CATALINA_HOME: /usr/share/apache-tomcat-9.0.8
Using CATALINA_TMPDIR: /usr/share/apache-tomcat-9.0.8/temp
Using JRE_HOME: /usr/lib/jvm/java-8-oracle
Using CLASSPATH: /usr/share/apache-tomcat-9.0.8/bin/bootstrap.jar:/usr/share/apache-tomcat-9.0.8/bin/tomcat-juli.jar
Tomcat started.

If the start was successful, you should see port 8080 on your system being used by a Java process.

# ss -tunelp | grep 8080
tcp LISTEN 0 100 *:8080 *:* users:(("java",pid=15131,fd=49)) ino:9110112 sk:18 v6only:0 <->

Try to access port 8080 on your web browser using the server IP address or its hostname:

install tomcat ubuntu 18.04 ui

As an appreciation for the content we put out,
we would be thrilled if you support us!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


Please enter your comment!
Please enter your name here