Up to $100 off Dedicated Servers

How to Install Apache Tomcat 9 on Ubuntu 18.04

Posted on by Echo Diaz
Reading Time: 3 minutes

Apache Tomcat is an accessible, open-source application server used to house many of today applications. It's free, stable, lightweight and is utilized to render Java coding as well a range of other applications.

Today we will be focusing on how to install Apache Tomcat 9 on our Liquid Web Ubuntu server, specifically Ubuntu 18.04 LTS.


  • Open the terminal and log in as root. If you are logged in as another user, you will need to add sudo before each command.
  • Working on a Linux Ubuntu VPS server

Step 1

Install or Verify Java 8 is installed

java -version

If nothing is returned or you get the message “No such file or directory” then you’ll need to install Java 8.

In this case, we’ll be installing OpenJDK 8 because it's free and, the OracleJDK recently reached its EOL in January 2019.

apt install default-jdk -y

If Java was installed successfully, you’d see something like this when using the java -version command

java -version


openjdk version "10.0.2" 2018-07-17
OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4)
OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4, mixed mode)

Step 2

Install Tomcat 9

wget https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.8/bin/apache-tomcat-9.0.8.tar.gz

Step 3

Extract Tomcat 9 Tarball

However, fun to think about, this tarball doesn't belong to any cat, it belongs to Tomcat!

We'll be moving this tarball into the /opt/tomcat directory.

mkdir /opt/tomcat

mv apache-tomcat-9.0.8.tar.gz /opt/tomcat

tar -xvzf /opt/tomcat/apache-tomcat-9.0.8.tar.gz

Step 4

Create a Tomcat user

We create the tomcat user as extra security as this user will be the one who has group ownership to the Tomcat files.

groupadd tomcat

useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat

Step 5

Update permissions to Tomcat

Since Tomcat belongs to the group category, we have to update the permission for some of the directories of Tomcat.

chgrp -R tomcat /opt/tomcat

cd /opt/tomcat/apache-tomcat-9.0.8

chmod -R g+r conf

chmod g+x conf

chown -R tomcat webapps/ work/ temp/ logs/

Step 6

Create a Systemd Service File

Copy the path of Tomcat’s home by running this command:

update-java-alternatives -l

java-1.11.0-openjdk-amd64      1101       /usr/lib/jvm/java-1.11.0-openjdk-amd64</b

Your path may look different but, that's alright, take the highlighted path and put it into your /etc/systemd/system/tomcat.service file, as the JAVA_HOME variable (shown below).

vim /etc/systemd/system/tomcat.service

Just as the path may look different from our example, you’ll focus on providing the variables in this file the path to our Tomcat installation(a.k.a. Tomcat’s root directory). For example, we’ll let the server know that the startup.sh and shutdown.sh files are located in the /bin directory of Tomcat. At any rate, be sure that your paths (bolded in the example) are the correct paths.

Description=Apache Tomcat
After=syslog.target network.target
Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'

Be sure to save the file by using :wq

Step 7

Reload the Systemd File

We do this so the system can recognize the changes to the file that we just edited.

systemctl daemon-reload

Step 8

Restart Tomcat

systemctl start tomcat

If the Tomcat service fails to start use journalctl -xn as a way to know the exact errors that are occurring.

Step 9

Verify Tomcat is Running

systemctl status tomcat


* tomcat.service - Apache Tomcat
Loaded: loaded (/etc/systemd/system/tomcat.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2019-04-04 14:33:04 EDT; 4min 29s ago
Process: 10912 ExecStart=/opt/tomcat/apache-tomcat-9.0.8/bin/startup.sh (code=exited, status=0/SUCCESS)
Main PID: 10930 (java)
Tasks: 47 (limit: 2157)
CGroup: /system.slice/tomcat.service
`-10930 /usr/lib/jvm/java-1.11.0-openjdk-amd64/bin/java -Djava.util.logging.config.file=/opt/tomcat/apache-tomcat-9.0.8/conf/logging.properties -Djava.util.logging.manage

If correctly installed you’ll also be able to see the Tomcat default page by visiting http://Host_IP:8080 in your browser, replacing Host_IP with your server’s IP or hostname, followed by Tomcat’s port number 8080.


The Most Helpful Humans In Hosting™

We pride ourselves on being The Most Helpful Humans In Hosting™! Our support staff is always available to assist with any Dedicated, Cloud, or VPS server issues 24 hours a day, 7 days a week 365 days a year.

We are available, via our ticketing systems at support@liquidweb.com, by phone (at 800-580-4986) or via a LiveChat for whatever method you prefer. We work hard for you so you can relax.

Avatar for Echo Diaz

About the Author: Echo Diaz

Throughout Echo's four year stint as a technical support specialist, her passion for breaking down complex concepts had to lead to a career in professional writing. As a former top tier support specialist, she added a distinctive element to her written work that spoke to customer feedback and concerns. Echo occasionally pops her head out from behind her computer to watch her dog energetically run around the yard and unabashedly shovels money into buying tickets to see her favorite musical artists.

Latest Articles

Best authentication practices for email senders

Read Article

2024 cPanel and Plesk pricing breakdown

Read Article

CentOS Linux 7 EOL — everything you need to know

Read Article

How to install Node.js on Linux (AlmaLinux)

Read Article

Upgrading or installing PHP on Ubuntu — PHP 7.2 and Ubuntu 22.04

Read Article