Install Apache Tomcat 8 on Ubuntu 14.04

Install Java
sudo su
sudo apt-get install default-jdk
Install Tomcat
Download the and extract the Tomcat package. New versions can be download from Tomcat wesbite.

cd /opt

Extract the package

tar xvzf apache-tomcat-8.0.37.tar.gz

Rename folder "apache-tomcat-8.0.37" to "tomcat"

mv apache-tomcat-8.0.37 tomcat

Delete the package file from /opt folder

rm apache-tomcat-8.0.37.tar.gz

Create Tomcat user and add to the group

sudo su
sudo groupadd tomcat
sudo useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat

Folder permissions

cd /opt/tomcat
sudo chgrp -R tomcat conf
sudo chmod g+rwx conf
sudo chmod g+r conf/*

sudo chown -R tomcat work/ temp/ logs/

Setup environment variablesEnvironment variables to find JAVA.
Add following lines at the bottom of the file,

export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export CATALINA_HOME=/opt/tomcat

Running Tomcat automatically
You can set up to start the Tomcat server start automatically at the time of system turn on.
Open following file in a Terminal,

leafpad  /etc/init.d/tomcat

Add following lines in the file,

# Provides:        tomcat7
# Required-Start:  $network
# Required-Stop:   $network
# Default-Start:   2 3 4 5
# Default-Stop:    0 1 6
# Short-Description: Start/Stop Tomcat server


start() {
 sh /opt/tomcat/bin/

stop() {
 sh /opt/tomcat/bin/

case $1 in
  start|stop) $1;;
  restart) stop; start;;
  *) echo "Run as $0 <start|stop|restart>"; exit 1;;

save and close the file.

Apply following commands too,

chmod +x /etc/init.d/tomcat
update-rc.d tomcat defaults

Start Tomcat server,

service tomcat start

Now you can start and stop Tomcat server using following commands;

service tomcat start
service tomcat stop
service tomcat restart

Open your browser and load Tomcat: 

No comments:

Post a Comment