This document will only discuss Tomcat 5. Old documentation for Tomcat 4 can be found here.
/usr/local.
$ su - # mv $HOME/src/jakarta-tomcat-5.0.19.tar.gz /usr/local # cd /usr/local # gzip -d jakarta-tomcat-5.0.19.tar.gz # tar -xvf jarkarta-tomcat-5.0.19.tar
$CATALINA_HOME envirnoment variable to your PATH.
# vi /etc/profile CATALINA_HOME=/usr/local/jakarta-tomcat-5.0.19 export CATALINA_HOME
NOTE: You may want to set up a symbolic link to /usr/local/jakarta-tomcat
# cd /usr/local/jakarta-tomcat-5.0.19/bin (cd $CATALINA_HOME/bin) # ./startup.sh or simply # $CATALINA_HOME/bin/startup.sh
# cd /usr/local/jakarta-tomcat-5.0.19/bin (cd $CATALINA_HOME/bin) # ./shutdown.sh or simply # $CATALINA_HOME/bin/shutdown.sh
http://localhost:8080
and you should see the default Tomcat page. This page includes JSP and Servlet examples for you to try.
################TODO######################################
server.xml file located at $TOMCAT_HOME/conf/server.xml.
We need to add a new Context configuration. I'm going to add a Context named "sparling":
<Context path="/sparling"
docBase="webapps/sparling"
crossContext="false"
reloadable="true">
</Context>
Refer to the User's Guide for an explantation of these lines.
Now we need to create the sparling directory to $TOMCAT_HOME/webapps.
# cd $CATALINA_HOME # cd webapps # mkdir sparling # cd sparling # mkdir WEB-INF # cd WEB-INF # mkdir classesNow restart Tomcat. This will rebuild the tomcat-apache.conf file.
Now move your servlet class file to the $CATALINA_HOME/webapps/sparling/WEB-INF/classes directory. For example, if we add the file HelloWorld.class to this directory, then we can access the servlet via the browser at: http://localhost:8080/sparling/servlet/HelloWorld.
Create tomcat user # chown -R tomcat /usr/local/jakarta-tomcat-4.1.18 Create/edit /etc/rc.d/init.d/tomcat
#!/bin/sh
#
# Startup script for Tomcat
JAVA_HOME=/usr/java/j2sdk1.4.1_03
export JAVA_HOME
start_tomcat=/usr/local/jakarta-tomcat-4.1.18/bin/startup.sh
stop_tomcat=/usr/local/jakarta-tomcat-4.1.18/bin/shutdown.sh
start() {
echo -n "Starting tomcat: "
su -c ${start_tomcat} - tomcat
echo "done."
}
stop() {
#echo -n "Shutting down http: "
echo -n "Shutting down tomcat: "
${stop_tomcat}
echo "done."
}
# See how we were called
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 10
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
exit 0
export CLASSPATH=$CLASSPATH:$CATALINA_HOME/common/lib/servlet.jar<29-Mar-2004>