Tuesday, November 17, 2015

Red Hat Example of installing Tomcat

# cd /tmp
# tar -xzf  apache-tomcat-6.0.29.tar.gz
# mv apache-tomcat-6 /usr/local
# cd /usr/local
# ln -s apache-tomcat-6
# yum install java-1.6-openjdk.i386 -> required package
# yum install httpd --> required package
# ls -l /usr/bin/java
# ls -l /etc/alternatives/java
# java -version
# cd /root
# vi .bash_profile
CATALINA_HOME = /usr/local/tomcat
export CATALINA_HOME
JAVA_HOME = /usr/lib/jvm/jre-1.6-openjdk
# . .bash_profile
# env | grep -i CATALINA
# env | grep -i JAVA
# cd /etc/init.d
vi tomcat
# this is the init script for starting up the tomcat server
# chkconfig:345 91 10
# description: start and stop tomcat deamon
# source function library
. /etc/rc.d/init.d/functions
#Get config
. /etc/sysconfig/network
# check that networking in up
[ "${NETWORKING}"="no"] && exit 0

tomcat = /usr/local/tomcat
startup=$tomcat/bin/startup.sh
shutdown = $tomcat/bin/shutdown.sh
export JAVA_HOME=/usr/lib/jvm/jre-1.6-openjdk

start(){  echo -n $"starting Tomcat service:"
#demon -c
$startup
RETVAL=$?
echo
}

stop(){  action  $"stopping Tomcat service:  "
$ shutdown
RETVAL = $?
echo}

restart(){
stop
start
}

## see how we were called

case "$1" in
start)  
start
;;
stop)
stop
;;
status)
#doesn't work
status tomcat
;;
restart)
restart
;;
*)
echo $"usuage : $0 {start|stop|status|restart}"
exit 1
;;

esac

exit 0

# chmod 755 tomcat
# vi /etc/sysconfig/iptables

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -dport 80 -j ACCEPT

# service iptables restart
# chkconfig --add tomcat
# chkconfig --list | grep -i tomcat
# service tomcat start
# service httpd start --> if it has not started yet
#  ps -ef  | grep -i tomcat