How to install tomcat7 + centos6

Post Reply
a24uall
Site Admin
Posts: 166
Joined: Sun Jul 01, 2012 9:07 am

How to install tomcat7 + centos6

Post by a24uall »

You may first need to install JDK
cd /usr/local/src
Download the latest jdk from
http://www.oracle.com/technetwork/java/ ... 80260.html
Download the rpm file for eg : jdk-7u21-linux-x64.rpm
mv jdk-7u21-linux-x64.rpm\?AuthParam\=1368006222_2c6faa20e11d439c32634260112ed060 jdk-7u21-linux-x64.rpm
Install uisng
rpm -ivh jdk-7u21-linux-x64.rpm
If it shows an error
Package jdk-7u21-linux-x64.rpm is not signed

you can fix that using :
viewtopic.php?f=42&t=129
cd /usr/share/
Download tomcat latest version from :
http://apache.techartifact.com/mirror/t ... .39.tar.gz
Untar the file and enter the "bin" folder
tar -xvzf apache-tomcat-7.0.39.tar.gz
cd apache-tomcat-7.0.39/bin
vi catalina.sh
Change the variable "JAVA_HOME" as mentioned below :
JAVA_HOME=/usr/java/jdk1.7.0_21
You can now start stop tomcat using
./startup.sh
./shutdown.sh
Now we can add tomcat as a service
cd /etc/init.d
vi tomcat
Add the below lines to the file

Code: Select all

#!/bin/bash
# chkconfig: 234 20 80
# description: Tomcat Server basic start/shutdown script
# processname: tomcat
JAVA_HOME=/usr/java/jdk1.7.0_21
export JAVA_HOME
TOMCAT_HOME=/usr/share/apache-tomcat-7.0.39/bin
START_TOMCAT=/usr/share/apache-tomcat-7.0.39/bin/startup.sh
STOP_TOMCAT=/usr/share/apache-tomcat-7.0.39/bin/shutdown.sh
start() {
echo -n "Starting tomcat: "
cd $TOMCAT_HOME
${START_TOMCAT}
echo "done."
}
stop() {
echo -n "Shutting down tomcat: "
cd $TOMCAT_HOME
${STOP_TOMCAT}
echo "done."
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 10
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
exit 0
chmod 755 tomcat
service tomcat restart
chkconfig --add tomcat
chkconfig tomcat on

You should now view the tomcat manager from the URL : IP_ADDRESS:8080

How to bind tomcat to port 80 of a specific Ip address :
vi /usr/share/apache-tomcat-7.0.39/conf/server.xml
On line 70 change the below :
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
to
<Connector port="80"
protocol="HTTP/1.1"
address="68.171.223.6"
connectionTimeout="20000"
redirectPort="8443" />
How to configure tomcat manager
Follow :
viewtopic.php?f=121&t=130&p=145&hilit=manager#p145
Arun
WebhostingDevelopment.com
Post Reply

Return to “Webservers Installation”