Apache Tomcat is a web application container that is used to serve Java servlet applications. This How To covers the basic installation of Tomcat 8 on a Ubuntu Server 14.04.
You need a running Ubuntu Server 14.04 installation, an actual Java JDK version 7 or 8.
Create a Tomcat User
For security reasons, Tomcat should be run as an unprivileged user. So, we will create a new Tomcat user and group that will run the Tomcat service.
Create a new Tomcat group:
$ sudo groupadd tomcat
Then we create a new Tomcat user, which is a member of the Tomcat group, with a home directory of /tmp with the following command:
$ sudo useradd -s /bin/false -g tomcat -d /tmp tomcat
Our Tomcat user is set up.
You have to download the latest Tomcat 8 binary distribution and extract the packed file into the /opt directory and rename the Tomcat installation directory to tomcat8:
$ cd /opt
$ sudo tar xvfz apache-tomcat-8*tar.gz
$ sudo mv apache-tomcat8* tomcat8
We give the Tomcat user write/read access to specific files and directories:
Change into Tomcat installation path:
$ cd /opt/tomcat8
Set the permissions:
$ sudo chgrp -R tomcat conf
$ sudo chmod g+rwx conf
$ sudo chmod g+r conf/*
We have also to make the Tomcat user the owner of the work, temp, and logs directories:
$ sudo chmod -R tomcat work/ temp/ logs/
Install Upstart Script
Because we want to run Tomcat as a service, we neet to set up an Upstart script.
Create an Upstart script:
$ sudo vi /etc/init/tomcat.conf
Copy and paste the following script into the created tomcat.conf file:
description "Tomcat8 Production Server"
start on runlevel 
stop on runlevel [!2345]
respawn limit 10 5
# Modify these options as needed
env JAVA_OPTS="-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom"
env CATALINA_OPTS="-Xms512M -Xmx1024M -server -XX:+UseParallelGC"
exec $CATALINA_HOME/bin/catalina.sh run
# cleanup temp directory after stop
rm -rf $CATALINA_HOME/temp/*
This script is used to run the Tomcat service with the unprivileged Tomcat user.
Now we need to reload the Upstart configuration:
$ sudo initctl reload-configuration
Let’s start the Tomcat service with the following command:
$ sudo initctl start tomcat
Tomcat is now running and accessable with the domain or IP address followed by the default port :8080 in a web browser. Open the URL http://server_IP_address:8080 in w web browser.