1. Create an application/domain user:
2. Install Tomcat by copying and unzipping an archive:
$ unzip apache-tomcat-7.0.12.zip -d tomcat7
3. Create a service configuration for Tomcat 7:
$ edit tomcat7-supersite
#
# tomcat7-supersite
#
# chkconfig: – 81 21
#
# description: Tomcat 7 (supersite) startup script
#
# Source function library.
. /etc/init.d/functions
#Test root privilages
RETVAL=$?
test $EUID = 0 || exit 4
CATALINA_HOME=/home/supersite/tomcat7
JAVA_HOME=/usr/lib/jvm/jdk1.6.0_24
TOMCAT_OWNER=supersite
CATALINA_PID=$CATALINA_HOME/bin/tomcat.pid
export CATALINA_HOME
export JAVA_HOME
export TOMCAT_OWNER
export CATALINA_PID
start() {
rm -f $CATALINA_PID
echo -n "Starting Tomcat for $TOMCAT_OWNER: "
su $TOMCAT_OWNER -c $CATALINA_HOME/bin/startup.sh
sleep 2
}
stop() {
echo -n "Stopping Tomcat for $TOMCAT_OWNER: "
su $TOMCAT_OWNER -c $CATALINA_HOME/bin/shutdown.sh
}
restart() {
# Restart
stop
echo "Sleeping for 20 seconds …"
sleep 20
start
}
status() {
RETVAL="1"
if [ -f "${CATALINA_PID}" ]; then
read kpid < $CATALINA_PID
if checkpid $kpid 2>&1; then
echo "$0 is already running (${kpid})"
RETVAL="0"
else
echo "lock file found but no process running for pid $kpid"
fi
else
pid="$(pgrep -u ${TOMCAT_OWNER} java)"
if [ -n "$pid" ]; then
echo "$0 running (${pid}) but no PID file exists"
RETVAL="0"
else
echo "$0 is stopped"
fi
fi
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status
;;
version)
parseOptions
"${JAVA_HOME}/bin/java" \
-classpath "${CATALINA_HOME}/server/lib/catalina.jar" \
org.apache.catalina.util.ServerInfo
;;
*)
echo $"Usage: tomcat {start|stop|restart}"
exit 1
esac
exit $RETVAL
4. Verify the service config with commands:
$ service tomcat7-supersite status
$ service tomcat7-supersite restart
$ service tomcat7-supersite stop
5. Configure an AJP connector in $TOMCAT_HOME/conf/service.xml:
If you don’t want your Tomcat to be exposed for direct HTTP requests comment out HTTP/1.1 connector section.
6. Configure Tomcat to respond to the supersite domain (e.g., supersite.com):
<Host name="supersite.com" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
<Alias>www.supersite.com</Alias>
</Host>
</Engine>
7. Update your mod_jk to the latest version by getting an appropriate for your system mod_jk*.so file from http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/:
$ mv mod_jk.so mod_jk.bk
$ wget -O mod_jk.so http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/linux/jk-1.2.31/x86_64/mod_jk-1.2.31-httpd-2.2.x.so
$ chmod 755 mod_jk.so
8. Create a new domain (supersite.com) using Plesk panel.
9. Configure your Apache to use mod_jk for the supersite domain:
$ edit vhost.conf
JkMount /* ajp-veneve
Then execute the following to ask Plesk to include your new vhost.conf into httpd.include:
Create jk.conf:
$ edit jk.conf
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info
JkLogStampFormat “[%a %b %d %H:%M:%S %Y]“
Create workers.properties in /etc/httpd/conf:
worker.ajp-supersite.port=8010
worker.ajp-supersite.host=localhost
worker.ajp-supersite.type=ajp13
10. Restart Apache:
11. Deploy you application to Tomcat by copying war file to /home/supersite/tomcat7/webapps. You can also deploy your application as a ROOT application by either renaming the war file to ROOT.war or replacing content of the existing ROOT directory with the war content.
12. Verify if the Tomcat it responding by going to http://supersite.com (also verify http://www.supersite.com).
13. Check Tomcat logs in $TOMCAT_HOME/logs/catalina.out if your application failed to start. This will help to diagnose a possible issue with the application itself.
