• Get In Touch
March 29, 2016

How to Install And Configure Apache Tomcat 8 on Ubuntu 15.10

Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month.
Get a Cloud Server

Overview

Previously we already learned how-to install and configure Apache Tomcat 7 on Ubuntu 14.04. In this tutorial we will learn how-to install Apache Tomcat 8 on Ubuntu 15.10.

Apache Tomcat is an open source software implementation of the Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies.

Apache Tomcated is powered many large sites and applications world wide, including but not limited to walmart.com, Alfresco, CiteSeerX. We can see a list of sites and applications PoweredBy page on Apache Tomcat wiki.

Updating Base System

This tutorial assumes that we have clean install of Ubuntu 15.10 Server. Before we install Apache Tomcat 8 and its prerequisites let’s update our base system.

$ sudo apt-get update
$ sudo apt-get upgrade

Installing JDK 8

Now, let’s install Java Development Kit 8. We will use the Oracle JDK instead of OpenJDK version of JDK 8.

Add the webupd8team ppa repository :

$ sudo add-apt-repository ppa:webupd8team/java
...
Press [ENTER] to continue or ctrl-c to cancel adding it

...
OK

We need to press enter to continue adding the webupd8team PPA repository. The output is truncated above to show you only the most important part.

Let apt-get download and read the metadata of the new repository that we just added:

$ sudo apt-get update

Install JDK 8.

$ sudo apt-get -y install oracle-java8-installer

The -y option above will make you agree automatically with packages to be installed including dependencies. If you want to check what packages will be installed you can remove the -y option above.

Package configuration. Choose OK

https://i.imgur.com/uHoqkrn.png
Accepting Oracle Binary Code Lisence Terms. Choose Yes

https://i.imgur.com/8H9A2LH.png

After installing Java 8, you can check the current java version by running the command below :

$ java -version
java version "1.8.0_74"
Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode)

We’ve confirmed that we already have JDK 8 installed.

Installing Apache Tomcat 8

Now we’re ready to install Apache Tomcat 8. To install Apache Tomcat 8 we can run the command below :

$ sudo apt-get -y install tomcat8

Apache Tomcat 8 should now be installed. Let’s check the tomcat8 service status using command below:

$ sudo service tomcat8 status
● tomcat8.service - LSB: Start Tomcat.
   Loaded: loaded (/etc/init.d/tomcat8)
   Active: active (running) since Tue 2016-03-22 23:07:55 UTC; 38s ago
``` language-bash
     Docs: man:systemd-sysv-generator(8)
</code></pre>

CGroup: /system.slice/tomcat8.service

<pre><code class="language-bash">           └─15286 /usr/lib/jvm/java-8-oracle/bin/java -Djava.util.logging.config.file=/var/lib/tomcat8/conf/logging.properties -Djava.util.logging.manage...
</code></pre>

Mar 22 23:07:50 vagrant-ubuntu-wily-64 systemd[1]: Starting LSB: Start Tomcat....
Mar 22 23:07:50 vagrant-ubuntu-wily-64 tomcat8[15263]: * Starting Tomcat servlet engine tomcat8
Mar 22 23:07:55 vagrant-ubuntu-wily-64 tomcat8[15263]: ...done.
Mar 22 23:07:55 vagrant-ubuntu-wily-64 systemd[1]: Started LSB: Start Tomcat..

<pre><code><br />We can also check whether the tomcat8 process is already listening on the correct port or not. By default tomcat listens on port 8080.
</code></pre>

$ sudo netstat -naptu | grep java
tcp6       0      0 :::8080                 :::*                    LISTEN      15286/java<br />
tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN      15286/java

<pre><code><br />We can see from both of the outputs above that tomcat is already running. Now from our browser, open http://:8080. You should see a page like below :

![https://i.imgur.com/lvjkmtP.png](https://i.imgur.com/lvjkmtP.png)

## Install Tomcat 8 Web Admin
Tomcat 8 has a web based application to manage its own service and application running on top of it. It's not installed by default. We will install the ```tomcat8-admin``` package first before configuring a user for Tomcat 8 Web Admin. We can run the command below to install tomcat8 admin:

$ sudo apt-get -y install tomcat8-admin


## Install Tomcat 8 Documentation and Examples If this is not a production machine, we can also install Tomcat 8 Documentation and an example package. We can use the commmand below to install documentation and example packages:

$ sudo apt-get -y install tomcat8-docs tomcat8-examples

However, if this is a production machine, it's recommended to only install ```tomcat8``` and ```tomcat8-admin``` packages.

## Configure Admin User on Apache Tomcat 8

The Tomcat 8 web manager admin does not ship with default username and password. We have to add a username and put the user to the correct role. 

There are four roles available that we can use. The available roles are:

* manager-gui — Access to the HTML interface.
* manager-status — Access to the "Server Status" page only.
* manager-script — Access to the tools-friendly plain text interface that is described in this document, and to the "Server Status" page.
* manager-jmx — Access to JMX proxy interface and to the "Server Status" page.
In this tutorial we will add the ```hostpresto``` user, and add this user to the ```manager-gui``` role.
Open ```/etc/tomcat8/tomcat-users.xml``` using a text editor. We will need open the text editor using the ```sudo``` command.
Find `````` at the end of the file, above this line, add the line :
Don't forget to change the password ```verysecretchangeme``` above.

Restart the tomcat8 service so the configuration changes are applied :

$ sudo service tomcat8 restart
Now point your browser tohttp://:8080/manager/html“`. It will show you a login prompt. We can login to the Tomcat Web Application Manager that we created above.

https://i.imgur.com/olmLOIU.png

After logging in we can manage tomcat using the Tomcat Web Application Manager. On the top of the page we can see a list of applications deployed on this tomcat 8 server.

https://i.imgur.com/ViPngTt.png

On the bottom, we can deploy a new application from this web manager by uploading a .war file.

https://i.imgur.com/K5du80p.png
We can also see the status of the server by clicking the Server Status link or open http://:8080/manager/status in your browser.

https://i.imgur.com/mFxCzpJ.png

Summary

In this tutorial we learned how-to install Tomcat 8 on Ubuntu 15.10. We also installed Tomcat web application manager and configured the administrator level user with role manager-gui role.

Now you can start deploying your own applications on Tomcat 8. Have Fun!

Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month.
Get a Cloud Server

Share this Article!

Related Posts

Node.js Authentication – A Complete Guide with Passport and JWT

Node.js Authentication – A Complete Guide with Passport and JWT

Truth be told, it’s difficult for a web application that doesn’t have some kind of identification, even if you don’t see it as a security measure in and of itself. The Internet is a kind of lawless land, and even on free services like Google’s, authentication ensures that abuses will be avoided or at least […]

Node.js and MongoDB: How to Connect MongoDB With Node

Node.js and MongoDB: How to Connect MongoDB With Node

MongoDB is a document-oriented NoSQL database, which was born in 2007 in California as a service to be used within a larger project, but which soon became an independent and open-source product. It stores documents in JSON, a format based on JavaScript and simpler than XML, but still with good expressiveness. It is the dominant […]

Using MySQL with Node.js: A Complete Tutorial

Using MySQL with Node.js: A Complete Tutorial

Although data persistence is almost always a fundamental element of applications, Node.js has no native integration with databases. Everything is delegated to third-party libraries to be included manually, in addition to the standard APIs. Although MongoDB and other non-relational databases are the most common choice with Node because if you need to scale an application, […]

Node.Js Vs Django: Which Is the Best for Your Project

Node.Js Vs Django: Which Is the Best for Your Project

Django and NodeJs are two powerful technologies for web development, both have great functionality, versatile applications, and a great user interface. Both are open source and can be used for free. But which one fits your project best? NodeJs is based on JavaScript, while Django is written in Python. These are two equally popular technologies […]

Nodejs Vs PHP:  Which Works Best?

Nodejs Vs PHP: Which Works Best?

Before getting into the “battle” between Node.js and PHP we need to understand why the issue is still ongoing. It all started with the increased demand for smartphone applications, their success forcing developers to adapt to new back-end technologies that could handle a multitude of simultaneous requests. JavaScript has always been identified as a client-side […]