Installation of Apache Tomcat 8.5 on Ubuntu 20.04

Installation of Apache Tomcat 8.5

Step by step Installation of Apache Tomcat 8.5 on Ubuntu 20.04

For Installation of Apache Tomcat 8.5 do the following;

Step 1: For Installation of Apache Tomcat 8.5 Download the and extract the Tomcat package,

cd /opt
sudo wget http://mirrors.estointernet.in/apache/tomcat/tomcat-8/v8.5.50/bin/apache-tomcat-8.5.50.tar.gz

If the above mentioned link not working, visit Tomcat website and download the package.

sudo tar xvzf apache-tomcat-8.5.50.tar.gz

Step 2 : Rename folder “apache-tomcat-8.5.50” to “tomcat

sudo mv apache-tomcat-8.5.50 tomcat

Step 3: Delete the Tomcat package file from /opt folder

sudo rm apache-tomcat-8.5.50.tar.gz

Open the following file, 

sudo leafpad /etc/profile

Setup environment variables

Environment variables to find JAVA.

Add following lines at the bottom of the file,

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export CATALINA_HOE=/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,

sudo vim /etc/init.d/tomcat

Add following lines in the file,

#!/bin/bash
### BEGIN INIT INFO
# Provides:        tomcat8
# Required-Start:  $network
# Required-Stop:   $network
# Default-Start:   2 3 4 5
# Default-Stop:    0 1 6
# Short-Description: Start/Stop Tomcat server
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin

start() {
 sh /opt/tomcat/bin/startup.sh
}

stop() {
 sh /opt/tomcat/bin/shutdown.sh
}

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

save and close the file.

Apply the following commands too;

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

Start Tomcat server,

sudo service tomcat start

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

sudo service tomcat start
sudo service tomcat stop
sudo service tomcat restart

Leave a Reply