How to Install Tomcat 8 on Ubuntu 16.04 (Multiple Instances)

Apache Tomcat commonly called as Tomcat is an open source Webserver and Servlet container developed by Apache Software Foundation. It is written in Java and released under Apache 2.0 License. This is a cross platform application. Tomcat is actually composed of a number of components, including a Tomcat JSP engine and a variety of different connectors, but its core component is called Catalina. Catalina provides Tomcat's actual implementation of the servlet specification.

In this article, I'll provide you guidelines to install, configure and create multiple instances of Tomcat 8 on Ubuntu 16.04. Let's walk through the installations steps.

Since Tomcat is written in Java, we need Java to be installed on our server prior to the installation.

Install Java

Tomcat 8 requires, Java 7 or later versions to be installed on the server. I updated packages on my Ubuntu server and installed the JDK packages using the commands below:

root@ubuntu:~# apt-get update
root@ubuntu:~# apt-get install default-jdk
Setting up default-jdk-headless (2:1.8-56ubuntu2) ...
Setting up openjdk-8-jdk:amd64 (8u91-b14-0ubuntu4~16.04.1) ...
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/appletviewer to provide /usr/bin/appletviewer (appletviewer) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/jconsole to provide /usr/bin/jconsole (jconsole) in auto mode
Setting up default-jdk (2:1.8-56ubuntu2) ...
Setting up gconf-service-backend (3.2.6-3ubuntu6) ...
Setting up gconf2 (3.2.6-3ubuntu6) ...
Setting up libgnomevfs2-common (1:2.24.4-6.1ubuntu1) ...
Setting up libgnomevfs2-0:amd64 (1:2.24.4-6.1ubuntu1) ...
Setting up libgnome2-common (2.32.1-5ubuntu1) ...
Setting up libgnome-2-0:amd64 (2.32.1-5ubuntu1) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (229-4ubuntu4) ...
Processing triggers for ca-certificates (20160104ubuntu1) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...


Check and confirm the Java Version

After the installation process, just verify the Java version installed on your server.

root@ubuntu:~# java -version
openjdk version "1.8.0_91"
OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-0ubuntu4~16.04.1-b14)
OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)

Download / Install Tomcat

We can download the latest version of Tomcat here. Download and extract this under the folder /opt/apache-tomcat8.

root@ubuntu:/opt# wget
--2016-05-23 03:02:48--
Resolving (
Connecting to (||:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9842037 (9.4M) [application/zip]
Saving to: ‘’ 100%[===================================================================>] 9.39M 4.46MB/s in 2.1s

2016-05-23 03:02:51 (4.46 MB/s) - ‘’ saved [9842037/9842037]

Creating tomcat user / group

It is always recommended to run an application as a user instead of root user. Hence, I created a user named tomcat to run this application.

root@ubuntu:/opt# groupadd tomcat

root@ubuntu:/opt# useradd -g tomcat -s /bin/bash -d /opt/apache-tomcat8 tomcat

Now make all scripts under the Tomcat bin folder executable for the user.

root@ubuntu:/opt/apache-tomcat8/bin# chmod 700 *.sh

root@ubuntu:/opt# chown -R tomcat.tomcat apache-tomcat8/

Start the Tomcat Application

Now switch to the tomcat user and execute the script inside the Tomcat binary folder namely  /opt/apache-tomcat8/bin/ to run this application.

tomcat@ubuntu:~/bin$ sh
Using CATALINA_BASE: /opt/apache-tomcat8
Using CATALINA_HOME: /opt/apache-tomcat8
Using CATALINA_TMPDIR: /opt/apache-tomcat8/temp
Using JRE_HOME: /usr
Using CLASSPATH: /opt/apache-tomcat8/bin/bootstrap.jar:/opt/apache-tomcat8/bin/tomcat-juli.jar
Tomcat started.

Now we can access this URL http://serverip:8080 on the browser to confirm the Tomcat working.


We can even confirm the status using this command from CLI as below:

root@ubuntu:/opt# lsof -i :8080
java 22722 tomcat 53u IPv6 100669 0t0 TCP *:http-alt (LISTEN)

PS : To shutdown the application you can use the script inside the Tomcat binaries.

root@ubuntu:/opt/apache-tomcat8# sh bin/
Using CATALINA_BASE: /opt/apache-tomcat8
Using CATALINA_HOME: /opt/apache-tomcat8
Using CATALINA_TMPDIR: /opt/apache-tomcat8/temp
Using JRE_HOME: /usr
Using CLASSPATH: /opt/apache-tomcat8/bin/bootstrap.jar:/opt/apache-tomcat8/bin/tomcat-juli.jar
May 24, 2016 3:32:35 AM org.apache.catalina.startup.Catalina stopServer
SEVERE: Could not contact localhost:8005. Tomcat may not be running.
May 24, 2016 3:32:36 AM org.apache.catalina.startup.Catalina stopServer
SEVERE: Catalina.stop:

Tomcat Web Application Manager

In a production environment, it is very useful to have the capablility to deploy a new web application or undeploy an existing one, without having to shutdown/restart the entire server. In addition, you can even reload an exisiting application itself, even without declaring it to be reloadable in the Tomcat server configuration file.

This Management Web console supports the following functions:

  • Deploy a new web application from the uploaded WAR file or on a specified context path from the server f/s.
  • List the currently deployed web applications and the sessions that are currently active
  • Reload an existing web applications, to reflect changes in the contents of the /WEB-INF/classes or /WEB-INF/lib.
  • Get the server information about the OS and JVM
  • Start and Stop an existing web applications, --stopping the existing application thus making it unavailable. But don't undeploy it.
  • Undeploy a deployed web application and delete its document base directory

We can create the users to manage the Tomcat Management Web console. You can edit the Tomcat user configuration file namely conf/tomcat-users.xml  to create the admin users to manage the Panel.

I've appended  these lines to the Tomcat user configuration file to create two users namely manager and admin with the passwords as listed.

<user username="manager" password="tomcat123" roles="manager-gui" />

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

We can access the Tomcat Web Application Manager using the URL >>http://SERVERIP:8080/manager/ with the users created.


Enabling SSL/TLS support on Tomcat

Tomcat uses a password protected file "keystore" to save the SSL transactions. We need to create a keystore file to store the server's private key and self-signed certificate by executing the following command:

root@ubuntu:/usr/local# keytool -genkey -alias tomcat -keyalg RSA -keystore /usr/local/keystore
Enter keystore password:
Re-enter new password:
What is your first and last name?
[Unknown]: Saheetha Shameer
What is the name of your organizational unit?
[Unknown]: VIP
What is the name of your organization?
[Unknown]: VIP
What is the name of your City or Locality?
[Unknown]: Kochi
What is the name of your State or Province?
[Unknown]: Kerala
What is the two-letter country code for this unit?
[Unknown]: IN
Is CN=Saheetha Shameer, OU=VIP, O=VIP, L=Kochi, ST=Kerala, C=IN correct?
[no]: yes

Enter key password for <tomcat>
(RETURN if same as keystore password):


-genkeypair : Generate key pair

-keyalg : Key algorithm

-keystore : Keystore file path

After entering the details for generating the certification, you can edit the Tomcat server configuration to enable the SSL/TLS support directing to the keystore file.

We need to add this section to the Tomcat server configuration file namely conf/server.xml

<Connector port="8443" protocol="HTTP/1.1"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"

Restart the Tomcat application once confirming the keystore contents.

tomcat@ubuntu:~$ keytool -list -keystore /usr/local/keystore
Enter keystore password:

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

tomcat, May 23, 2016, PrivateKeyEntry,
Certificate fingerprint (SHA1): A3:99:A8:DD:F1:11:4F:69:37:95:11:66:41:59:A5:05:68:23:3E:B2

Now you can access the Tomcat application on the port 8443 on URL https://SERVER IP:8443 to confirm its working.


Creating Multiple Tomcat instances

In order to create multiple Tomcat instances, you can download and extract the Tomcat application to a different folder. I extracted the contents to a different folder namely /opt/apache-tomcat8-2. After extracting the files, we need to make proper changes to the Tomcat Server configuration file for modifying the Connector ports and other important ports for the application to avoid conflicts with the existing application.

These are the following changes applied to the Tomcat Server configuration file namely conf/server.xml.

1. Modified the shutdown port from 8005 to 8006

 <Server port="8005" shutdown="SHUTDOWN">


<Server port="8006" shutdown="SHUTDOWN">

2.  Modified the connector port from 8080 to 8081

<Connector port="8080" protocol="HTTP/1.1"

redirectPort="8443" />
<!-- A "Connector" using the shared thread pool-->


<Connector port="8081" protocol="HTTP/1.1"
redirectPort="8443" />
<!-- A "Connector" using the shared thread pool-->

3. Modified the AJP port  from 8009 to 8010

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

<Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />

After applying these changes, restart our new Tomcat Application under /opt/apache-tomcat8-2

root@ubuntu:/opt# chown -R tomcat.tomcat /opt/apache-tomcat8-2

root@ubuntu:/opt#cd apache-tomcat8-2

Making the script executable for the user.

root@ubuntu:/opt/apache-tomcat8-2# chmod 700 bin/*.sh

Switch to tomcat user and start the application.

tomcat@ubuntu:/opt/apache-tomcat8-2/bin$ sh
Using CATALINA_BASE: /opt/apache-tomcat8-2
Using CATALINA_HOME: /opt/apache-tomcat8-2
Using CATALINA_TMPDIR: /opt/apache-tomcat8-2/temp
Using JRE_HOME: /usr
Using CLASSPATH: /opt/apache-tomcat8-2/bin/bootstrap.jar:/opt/apache-tomcat8-2/bin/tomcat-juli.jar
Tomcat started.

Verify the second Tomcat instance at the port 8081 at the URL http://SERVERIP:8081


That's it! you're done with the basic things on Tomcat installations. I hope you enjoyed reading this article. I would recommend your valuable suggestions and comments on this. Thank you for reading this :)

Have a Good day!


Share This :

Free Linux Ebook to Download

Leave a Reply

Commenting Policy:
Promotion of your products ? Comment gets deleted.
All comments are subject to moderation.