Pages

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

wget http://redrockdigimark.com/apachemirror/tomcat/tomcat-8/v8.0.37/bin/apache-tomcat-8.0.37.tar.gz
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,

#!/bin/bash
### BEGIN INIT INFO
# 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
### 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 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:

http://127.0.1.1:8080 
Reference
https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-ubuntu-14-04 

No comments:

Post a Comment