Configure A Tomcat Instance to Use A Specific Version of Tomcat
Objectives
1. Configure a Tomcat instance to use a specific version of Tomcat.
Prerequisites
1. Administrative privileges on the tomcat server that you would like to change.
Instructions
1. Log into the tomcat server via ssh.
2. Find the directory that contains the version of Tomcat that you would like to use:
# ls -C1
/srv/tomcat/homes
#
TOMCAT_HOME="/srv/tomcat/homes/apache-tomcat-7.0.75"
# echo ${TOMCAT_HOME}
5. Find the basename of the directory that contains the version of Tomcat that you would like to use:
#
TOMCAT_BASE="$(basename ${TOMCAT_HOME})"
# echo ${TOMCAT_BASE}
3. Find the directory for the Tomcat instance that you would like to use a specific version of Tomcat:
# ls -C1
/srv/tomcat/instances
#
TOMCAT_INSTANCE="/srv/tomcat/instances/POSWebApplication"
# echo ${TOMCAT_INSTANCE}
4. Find the name of the service for the Tomcat instance:
#
SERVICE_NAME="$(basename ${TOMCAT_INSTANCE})"
# echo ${SERVICE_NAME}
6. As the "root" user, edit the init script for this Tomcat instance:
# vi /etc/init.d/${SERVICE_NAME}
7. Set the CATALINA_HOME variable to the basename from step 5:
:%s/export CATALINA_HOME="${BASE_DIR}/homes/tomcat7";/export CATALINA_HOME="${BASE_DIR}/homes/apache-tomcat-7.0.75";/g
8. Save your changes and quit:
:wq
9. Restart the Tomcat instance:
# service ${SERVICE_NAME} restart
10. Confirm that the Tomcat instance is using the correct version Tomcat:
# grep -h -n 'Server number:' ${TOMCAT_INSTANCE}/logs/catalina.log | tail -1
11. Send an email with output from the following commands to the Systems team:
# echo
"Hostname:
${HOSTNAME}"
# echo "Tomcat home directory:
${TOMCAT_HOME}"
# echo "Tomcat base directory:
${TOMCAT_BASE}"
# echo "Tomcat
instance: ${TOMCAT_INSTANCE}"
# echo "Tomcat service
name: ${SERVICE_NAME}"