Breaking News
Loading...
Sunday, August 18, 2013

How to install Tomcat 7.0.42 on CentOS 6.4



1. Introduction Tomcat
Apache Tomcat is an open source software implementation of the Java Servlet and JavaServer Pages technologies. The Java Servlet and JavaServer Pages specifications are developed under the Java Community Process.
Apache Tomcat is developed in an open and participatory environment and released under the Apache License version 2. Apache Tomcat is intended to be a collaboration of the best-of-breed developers from around the world. We invite you to participate in this open development project. To learn more about getting involved, click here.
Apache Tomcat powers numerous large-scale, mission-critical web applications across a diverse range of industries and organizations. Some of these users and their stories are listed on the PoweredBy wiki page.
Apache Tomcat, Tomcat, Apache, the Apache feather, and the Apache Tomcat project logo are trademarks of the Apache Software Foundation 
 2. Install Tomcat 7.0.42
Step 1: Download Tomcat
Before install Tomcat read How to Install JDK/JRE 7u25 on Linux CentOS 6.4/Redhat. Download and Unpack Tomcat 7. Find the latest download link here for the Core Tar file http://tomcat.apache.org/download-70.cgi
# cd /usr/share
# wget http://mirrors.digipower.vn/apache/tomcat/tomcat-7/v7.0.42/bin/apache-tomcat-7.0.42.tar.gz
# tar -xzf apache-tomcat-7.0.42.tar.gz
# cd /etc/init.d
# vi tomcat
In this new file copy the following:
#!/bin/bash
# description: Tomcat Start Stop Restart
# processname: tomcat
# chkconfig: 234 20 80
JAVA_HOME=/usr/java/jdk1.7.0_25
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/usr/share/apache-tomcat-7.0.42


case $1 in
start)
sh $CATALINA_HOME/bin/startup.sh
;;
stop)
sh $CATALINA_HOME/bin/shutdown.sh
;;
restart)
sh $CATALINA_HOME/bin/shutdown.sh
sh $CATALINA_HOME/bin/startup.sh
;;
esac
exit 0
Step 2: Save this and run the following command
# chmod 755 tomcat
# chkconfig --add tomcat
# chkconfig --level 234 tomcat on


Step 3: You can now start, stop and restart tomcat using:
#service tomcat stop
#service tomcat start
#service tomcat restart
Step 4: Allowing Port 80 through firewall and redirecting 8080 to port 80

#/sbin/iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT
#/sbin/iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT
#iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080   
#iptables -t nat -A PREROUTING -p udp -m udp --dport 80 -j REDIRECT --to-ports 8080
#/sbin/service iptables save
#service iptables restart
Step 5: Run Tomcat
http://ip:8080

3 comments:

  1. In the step:

    # cd /etc/init.d
    # vi /tomcat

    Remember to remove the / from "vi /tomcat". It should be just

    # cd /etc/init.d
    # vi tomcat

    ReplyDelete
  2. Thanks for the comments Ryan X :) (f)

    ReplyDelete

 
Toggle Footer