Table of Contents
Was this article helpful?

2  out of  3 found this helpful

Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $600 by adding new articles.

Install Tomcat on Ubuntu 16.04

Last Updated: Fri, Mar 23, 2018
Java Linux Guides Server Apps Ubuntu Web Servers
Archived content

This article is outdated and may not work correctly for current operating systems or software.

This guide explains how to install Apache Tomcat on an Ubuntu 16.04 server.


  • Deploy a new Ubuntu 16.04 server instance.

  • Create a non-root sudo user.

  • Log into the machine via SSH as the user you created.

Update your system

Make sure that you have the latest stable version of Ubuntu 16.04.

sudo apt-get update 

Install Java.

sudo apt-get install default-jdk 

Update the JAVA_HOME variable

Find the directory for JAVA_HOME.

update-alternatives --config java 

Copy the directory, and then type the following.

nano /etc/environment 

This will open up the file that contains environment variables.



The path in quotes is the path that you are using.

Save and close the file.

Reload the environment variables so that they take effect.

source /etc/environment 

Check to make sure that it worked:

echo $JAVA_HOME 

You will see the path you've entered.

Create a user to run the Tomcat web server

We will call this user 'tomcat', but you can use any name for this user.

groupadd tomcat

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

Make sure that you know the version of Tomcat that you want to install.

For this tutorial, we will use version 8.5.24, and the download link is as follows.

Remember to choose the download with a .gz extension.

Make a directory for the Tomcat files.

mkdir /opt/tomcat 

Download Tomcat.


wget your-tomcat-link 

Unzip the files into the tomcat folder.

tar xvf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1

You can press the "Tab" key after typing apache, since you only have one download in your folder.

Make sure that the folders have the correct permissions.

cd /opt/

sudo chown -R tomcat tomcat/

Display the JAVA_HOME path again, so that you can copy it.

nano /etc/systemd/system/tomcat.service 

Configure Tomcat

Copy and paste the settings below into the tomcat.service file you have just created. Edit the JAVA_HOME path to the one that you copied. After this, save and close the file.


Description=Apache Tomcat Web Application Container







Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'










Reload the SystemD daemon so that the service settings that were added are included.

sudo systemctl daemon-reload

Start the Tomcat service.

sudo systemctl start tomcat 

Check the status of your Tomcat server.

sudo systemctl status tomcat 

Browse to http://your_ip_address:8080

You will see the Tomcat server landing page.

Want to contribute?

You could earn up to $600 by adding new articles.