Setup Apache Tomcat9 on Ubuntu 16.04 | 17.10 | 18.04

Apache Tomcat software is an open source implementation of the Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket developed by the Apache Software Foundation… Although not as popular as Apache2 or Nginx HTTP servers, Tomcat is still important to some projects…

Tomcat works best when rendering web pages the include Java server page coding and Java Servlet… These languages are still required by some other protocols used by Java developers..

This brief tutorial is going to show students and new users how to instwall Tomcat on Ubuntu 16.04 / 17.10 and 18.04…

When you’re ready to install Tomcat, follow the steps below:

Step 1: Install Java JDK

Tomcat requires Java JDK to be installed in order to function… To install the original Java package, follow the guide below:

The easiest way to install Oracle Java JDK 8 on Ubuntu is via a third party PPA… To add that PPA, run the commands below

sudo add-apt-repository ppa:webupd8team/java

After running the commands above, you should see a prompt to accept the PPA key onto Ubuntu… accept and continue

Now that the PPA repository has been added to Ubuntu, run the commands below to download Oracle Java 8 installer…. the installer should install the latest Java JDK 8 on your Ubuntu machines.

sudo apt update
sudo apt install oracle-java8-installer

When you run the commands above you’ll be prompted to access the license terms of the software… accept and continue..

oracle java 9

Set Oracle JDK8 as default, to do that, install the oracle-java8-set-default package. This will automatically set the JAVA env variable.

sudo apt install oracle-java8-set-default

That should install Java JDK8 and configure it as the default…

Step 2: Download Tomcat Packages

Now that Java JDK is installed, run the commands below to donwnload Tomcat packages..

cd /tmp && wget

Then run the commands below to extract the downloaded packages.

tar -xzf apache-tomcat-9.0.8.tar.gz

Create a directory for Tomcat files… and move the files there by running the commands below….

sudo mv apache-tomcat-9.0.8 /opt/tomcat9

Create Tomcat users by running the commands below… this users will own the Tomcat directory content..

sudo useradd -r tomcat9 --shell /bin/false

Then give the user control of the directory…

sudo chown -R tomcat9 /opt/tomcat9

Step 3: Configure Tomcat9 Service

Now that the pakcage is extracted, run the commands to open Tomcat configuration file for its default user

sudo nano /opt/tomcat9/conf/tomcat-users.xml

Then create an account with password for the user and save by copying and pasting the line below into the file.. just before the </tomcat-users>

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

Save the file and exti..

Next, run the commands below to create a server account for Tomcat

sudo nano /etc/systemd/system/tomcat.service

then copy and paste the lines below into the file and save

Environment="CATALINA_OPTS=-Xms512m -Xmx512m"
Environment="JAVA_OPTS=-Dfile.encoding=UTF-8 -Dnet.sf.ehcache.skipUpdateCheck=true -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:+UseParNewGC"

Save and exit.

sudo systemctl daemon-reload
sudo systemctl start tomcat.service
sudo systemctl restart tomcat.service
sudo systemctl enable tomcat.service

Now, open your browser and browse to the local server IP or hostname


and you should see Tomcat default page..

Tomcat ubuntu install

Click on the Manager App to logon to the backend page…

Tomcat ubuntu install


You may also like the post below:


  1. Thank you for the simple tutorial

  2. Phillip H. Blanton

    This is an AWESOME tutorial. I used it to install Tomcat 8.5 on my Ubuntu 18.04 dev vm and I just replaced “Tomcat9” with “Tomcat85” in each command/config file entry and it worked flawlessly!

    I had already downloaded the Tomcat 8.5 tar file and I modified the tar command appropriately, but otherwise I followed the tutorial step-by-step and never had a single issue. I am used to using tutorials like these as a guideline but running into a myriad of errors that I have to troubleshoot, but your tutorial worked great!

    Thanks again!

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.