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
Accepting Oracle Binary Code Lisence Terms. Choose Yes
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 :

## 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 restartNow point your browser to
http://:8080/manager/html“`. It will show you a login prompt. We can login to the Tomcat Web Application Manager that we created above.
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.
On the bottom, we can deploy a new application from this web manager by uploading a .war file.
We can also see the status of the server by clicking the Server Status
link or open http://:8080/manager/status
in your browser.
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!