Tomcat installation



Tomcat Installation



  1. download tar file from https://archive.apache.org/dist/tomcat/tomcat-7/v7.0.42/bin/apache-tomcat-7.0.42.tar.gz
  2. extract to /usr/lib/ folder
  3. rename apache-tomcat-7.0.42 to tomcat
  4. In /etc/bash.bashrc set
    CATALINA_HOME=/usr/lib/tomcat
    PATH=$PATH:/usr/lib/tomcat/bin

To start tomcat as service



  1. create a file in /etc/init.d/ name it tomcat
  2. add this lines in tomcat

#!/bin/bash

### BEGIN INIT INFO

# Provides: tomcat

# 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 /usr/lib/tomcat/bin/startup.sh

}



stop() {

sh /usr/lib/tomcat/bin/shutdown.sh

}



case $1 in

start|stop) $1;;

restart) stop; start;;

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

esac



3. Give permissions to

 sudo chmod 755 /etc/init.d/tomcat

4. Add tomcat file update-rc.d
 sudo update-rc.d tomcat defaults
5. Now can start tomcat as service
sudo service tomcat start





Disable autostart for a tomcat service

update-rc.d tomcat disable

Note :-

If get JRE_HOME not found error  then update java alternatives

set java alternatives
  1. sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0_71/bin/java" 1
  2. sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0_71/bin/javac" 1
   

Comments

Popular posts from this blog

Proxy setting in java

Using logstash to import csv json files into elasticsearch

Kibana 4 Installation and Run as a service in ubuntu