Introduction

If you’re deploying Java web applications, you’ll eventually need a servlet container to run them — and Apache Tomcat is one of the most popular choices. This guide walks through how to install Tomcat server on Ubuntu 16, including Tomcat 8 and Java 1.8, and shows you how to secure the manager and admin GUIs with password authentication.

By the end of this post, you’ll have Tomcat running on port 8080 and be able to access the web-based manager interface securely.


Prerequisites

This guide assumes a fresh Ubuntu 16 host. If you also need a web server alongside Tomcat, see our related guide on installing Apache 2.4 and PHP on Ubuntu 16.04.


Steps to Install Tomcat Server on Ubuntu 16

Step 1: Update the System

Before installing Tomcat or Java, update and upgrade all existing packages:

apt-get update
apt-get upgrade

Step 2: Install Tomcat 8

Install the Tomcat 8 package. This will pull in Java 1.8 and other required dependencies — press Y when prompted to confirm installation:

apt-get install tomcat8

Step 3: Install the Documentation, Examples, and Admin Tools

These optional packages add the web-based manager GUI, sample applications, and documentation:

apt-get install tomcat8-docs tomcat8-examples tomcat8-admin

Step 4: Start and Enable Tomcat

Start the Tomcat service and enable it to launch automatically on boot:

systemctl start tomcat8
systemctl enable tomcat8

By default, Tomcat’s configuration files are located at /var/lib/tomcat8/conf/.

Step 5: Secure the Manager and Admin GUI

To access Tomcat’s web-based manager and admin interfaces, you need to define a user with the appropriate roles. Open the users configuration file:

vi /var/lib/tomcat8/conf/tomcat-users.xml

Add the following lines just before the closing </tomcat-users> tag:

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

Security note: Replace admin and password with a strong, unique username and password before deploying to any real environment. Leaving the default credentials in place is a serious security risk.

Step 6: Restart Tomcat

Apply the changes by restarting the service:

systemctl restart tomcat8

Accessing the Tomcat Manager Interface

Tomcat runs on port 8080 by default. Once the service is running, open the manager interface in your browser using your server’s IP address:

http://IPaddress:8080/manager/html

Alt text for reference image: “Tomcat 8 manager GUI login screen on Ubuntu”

If you followed the steps above, log in with the admin username and the password you configured (or password, if you’re just testing locally and haven’t changed the default yet).


Frequently Asked Questions

What Java version does Tomcat 8 require? Tomcat 8 works with Java 1.8, which is installed automatically as a dependency when you install tomcat8 on Ubuntu.

How do I change the default Tomcat port from 8080? Edit the Connector port value in /var/lib/tomcat8/conf/server.xml, then restart the tomcat8 service.

Is it safe to leave the default admin/password credentials? No. Always replace them with strong, unique credentials — especially before exposing the manager interface to the internet.


Conclusion

Installing Tomcat on Ubuntu 16 is a quick process: update your system, install the tomcat8 package along with the optional admin and docs packages, enable the service, and secure the manager GUI with proper credentials. With Tomcat running on port 8080, you’re ready to start deploying Java web applications.

Leave a Reply