How to install Tomcat 8 on Ubuntu 16.04?

[Last Updated: Apr 5, 2017]

Ubuntu Java Linux 

In this quick tutorial, we are going to install Tomcat 8 on Ubuntu 16.04.

To install Apache Tomcat, we need to have JRE installed already. Check out this quick walk-through if you have not installed JRE yet.

To install Tomcat 8, first update the apt-get package lists:

$sudo apt-get update

Now install tomcat8 and tomcat8-admin:

sudo apt-get install tomcat8
sudo apt-get install tomcat8-admin

Tomcat should be running now. Check the status:

systemctl status tomcat8.service

Edit the following:

sudo nano /etc/default/tomcat8

Make sure JAVA_OPTS has '' option as shown:

 JAVA_OPTS=" -Djava.awt.headless=true -Xmx128m -XX:+UseConcMarkSweepGC"

We can have Xmx to whatever value we want.

Note that tomcat 8 home folder is '/var/lib/tomcat8/'. Now we are going to set up user to access admin tools:

 $ sudo nano /var/lib/tomcat8/conf/tomcat-users.xml

Add the followings:

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

Restart tomcat:

 sudo systemctl restart tomcat8

At this point, we can access the tomcat home page and admin tools: http://server_domain_or_IP:8080

Note that, if you want to use Tomcat docs and examples, you need to install the followings:

sudo apt-get install tomcat8-docs tomcat8-examples

See Also