1. Downloadtomcat 7 from apache's website.
My downloaded package isapache-tomcat-7.0.32.tar.gz
2. Extract thepackage to /usr/share directory.
# tar xzvf apache-tomcat-7.0.32.tar.gz
# mv apache-tomcat-7.0.32 /usr/share
Now in /usr/share folder there is a apache-tomcat-7.0.32 folder.
You can also change this folder name totomcat7 or others you like.
So far tomcat can works if you import it to eclipse.
3. ConfigureTomcat to Run as a Service
Change to the /etc/init.d directory and create a script called 'tomcat' as shown below.
# cd /etc/init.d
# vi tomcat
Add the below item in tomcat file then save.
#!/bin/bash
# description:Tomcat Start Stop Restart
# processname:tomcat
# chkconfig: 23420 80
JAVA_HOME=/usr/lib/jvm/jdk1.7.0
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/usr/share/apache-tomcat-7.0.32
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
set the permissions to make it executable.
# chmod 755 tomcat
now use the chkconfig utility to have tomcat start at boot time
# chkconfig --add tomcat
# chkconfig --level 234 tomcat on
Verify it:
# chkconfig --list tomcat
Start tomcat:
# service tomcat start
Stop tomcat
# service tomcat stop
Restarting tomcat (Must be started first):
# service tomcat restart
We should review the Catalina.out loglocated at /usr/share/apache-tomcat-7.0.32/logs/catalina.out
and check for any errors.
# more/usr/share/apache-tomcat-7.0.32/logs/catalina.out
We can now access the Tomcat Manager page at:
http://yourdomain.com:8080 or http://yourIPaddress:8080 and we should see the Tomcat home page.
Until now on, tomcat can be used. There are some other features can be configed, detailed information
in this link:http://www.davidghedini.com/pg/entry/install_tomcat_7_on_centos