Java Plesk Technology Tomcat

Tomcat Upgrade on Plesk for Linux/Unix

This article describes how to upgrade Tomcat running under Plesk and how to disconnect the control Plesk has over the Tomcat server. This may not be the ideal configuration for you if you have many clients using JSP webapps. Your clients will no longer have the ability to use the Plesk war upload feature from the Plesk admin page.

Upgrade Java
If you plan to install the latest version of Tomcat on your server, you may need to upgrade to the latest version of Java as well. Many Plesk installations use Tomcat 4 and Java 1.4, so you may want Tomcat 5 + Java 5 or Tomcat 6 Java 6.

There are several ways to upgrade Java, and this article will give a simple outline without details.

You can download the latest Java JDK at this link. Note, you will need the stand alone JDK (java development kit) not with Netbeans, and not the JRE version.

Once you download the version for your platform, install the JDK. On Plesk 7.5, the current JVM is installed at /usr/lib/jvm The RPM install may install to this location. If you downloaded a tar package, you should move the expanded folder to this location.

Upgrade Tomcat

The latest version of Tomcat is available at this location

Because Tomcat runs on the Java virtual machine, you do not need to download a platform specific version or build the code on your server. Simply choose between the .zip or tar.gz download package.

On Plesk 7.5, Tomcat 4 is installed in /var/lib and you should install the new version there. Simply unzip or untar the Tomcat download package in /var/lib

Note – the following describes Tomcat 5. Substitute Tomcat 6 or greater if needed.

You should also create a symlink in /var folder called tomcat5, notice there should be a symlink there from the older Tomcat.

ln -s /var/lib/apache-tomcat-5.5.15/ tomcat5

Add a new Tomcat user and Group

Plesk uses a user and group of tomcat4 | tomcat4 and you should create a new group and user for your new Tomcat version.

groupadd tomcat5
useradd -G tomcat5 tomcat5

Modify the Startup Script

You should copy /etc/init.d/tomcat4 to /etc/init.d/tomcat5 and change all instances of ‘tomcat4’ to ‘tomcat5’

You should also make a symlink in /usr/bin

/usr/bin/dtomcat5 -> /var/tomcat5/bin/

# Startup script for Tomcat 5.0, the Apache Servlet Engine
# chkconfig: - 80 20
# description: Tomcat 5.0 is the Apache Servlet Engine RI for Servlet 2.3/JSP 1.2
# processname: tomcat
# pidfile: /var/run/
# config:  /etc/tomcat4/tomcat5.conf
# Gomez Henri 
# Keith Irwin 
# Nicolas Mailhot 
# version 1.02 - Removed initlog support
# version 1.03 - Removed config:
# version 1.04 - tomcat will start before httpd and stop after httpd
# version 1.05 - jdk hardcoded to link /usr/java/jdk and tomcat runs as "nobody"
# version 1.06 - split up into script and config file
# version 1.07 - Rework from Nicolas ideas
# version 1.08 - Fix work dir permission at start time, switch to use tomcat4
# version 1.09 - Fix pidfile and config tags
# version 1.10 - Fallback to su direct use on systems without Redhat/Mandrake init.d functions
# version 1.11 - Fix webapps dir permissions
# version 1.12 - remove initial start/stop level for chkconfig (- 80 20)
# version 1.13 - remove chown of logs/work/temp/webapps dir, owned by tomcat4 at install time
# version 1.14 - correct the start/stop ugly hack by waiting all the threads stops
# version 1.15 - ensure we're looking for TOMCAT_USER running catalina
# version 1.16 - Add support for CATALINA_PID env var
# version 1.17 - Remove run files only tomcat started correctl
#                in start area, check that tomcat is not allready running
# version 1.18 - Fix kill typo (thanks Kaj J. Niemi)
# version 1.19 - Add jar relinking
# version 1.20 - Check there is no stalling
# version 2.00 - updated to tomcat5

# Source function library.
if [ -x /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions


# Path to the tomcat launch script (direct don't use wrapper)

# Path to the script that will refresh jar symlinks on startup

# Tomcat name :)
# if TOMCAT_USER is not set, use tomcat4 like Apache HTTP server
if [ -z "$TOMCAT_USER" ]; then

# Since the daemon function will sandbox $tomcat
# no environment stuff should be defined here anymore.
# Please use the /etc/tomcat.conf file instead ; it will
# be read by the $tomcat script


# See how we were called.
start() {
    echo -n "Starting $TOMCAT_PROG: "

        if [ -f /var/lock/subsys/tomcat5 ] ; then
                if [ -f /var/run/ ]; then
                        read kpid < /var/run/
                        if checkpid $kpid 2>&1; then
                                echo "process allready running"
                                return -1
                                echo "lock file found but no process running for pid $kpid, continuing"
        export CATALINA_PID=/var/run/
        touch $CATALINA_PID


        if [ -x /etc/rc.d/init.d/functions ]; then
#               daemon --user $TOMCAT_USER $TOMCAT_SCRIPT start -security 
               daemon --user $TOMCAT_USER $TOMCAT_SCRIPT start
#               su - $TOMCAT_USER -c "$TOMCAT_SCRipT start -security"
                su - $TOMCAT_USER -c "$TOMCAT_SCRIPT start"

        [ $RETVAL = 0 ] && touch /var/lock/subsys/tomcat5
        return $RETVAL

stop() {
    echo -n "Stopping $TOMCAT_PROG: "

    if [ -f /var/lock/subsys/tomcat5 ] ; then
      if [ -x /etc/rc.d/init.d/functions ]; then
          daemon --user $TOMCAT_USER $TOMCAT_SCRIPT stop
          su - $TOMCAT_USER -c "$TOMCAT_SCRIPT stop"

      if [ 0 ]; then

        if [ -f /var/run/ ]; then

            read kpid < /var/run/
            let kwait=$SHUTDOWN_WAIT

            until [ `ps --pid $kpid | grep -c $kpid` = '0' ] || [ $count -gt $kwait ]
                echo "waiting for processes to exit";
                sleep 1
                let count=$count+1;

            if [ $count -gt $kwait ]; then
                echo "killing processes which didn't stop after $SHUTDOWN_WAIT seconds"
                kill -9 $kpid
                rm -f /var/lock/subsys/tomcat5 /var/run/


# See how we were called.
case "$1" in
        sleep 2
        if [ -f /var/run/ ] ; then
        echo "Usage: $TOMCAT_PROG {start|stop|restart|condrestart}"
        exit 1

exit $RETVAL

Modify Startup Symlinks

You will need to break the existing symlinks that point to the tomcat4 startup script and have them point to the tomcat5 script.

Your server's configuration may vary, but you should find similar links from the tomcat4 installation. Simply delete them and create new ones for Tomcat 5 that point to ../init.d/tomcat5

/etc/rc.d/rc0.d/K20tomcat4	/etc/rc.d/rc0.d/K20tomcat5
/etc/rc.d/rc1.d/K20tomcat4	/etc/rc.d/rc1.d/K20tomcat5
/etc/rc.d/rc2.d/S80tomcat4	/etc/rc.d/rc2.d/S80tomcat5
/etc/rc.d/rc3.d/S80tomcat4	/etc/rc.d/rc3.d/S80tomcat5
/etc/rc.d/rc4.d/S80tomcat4	/etc/rc.d/rc4.d/S80tomcat5
/etc/rc.d/rc5.d/S80tomcat4	/etc/rc.d/rc5.d/S80tomcat5
/etc/rc.d/rc6.d/K20tomcat4	/etc/rc.d/rc6.d/K20tomcat5

Get rid of mod_webapp

Plesk may have used mod_webapp to bridge Apache with Tomcat and pass all .JSP and servelet request to Tomcat. When upgrading Tomcat, you should also switch to the latest version of mod_jk

You will need to download and build the .so file and add this to your /etc/httpd/conf/htpd.conf file for Apache to include. Details of this process are not covered here, but should be a Google search away.
Also, you will most likely need to add a text file /etc/httpd/conf/

worker.list= ajp13

# Definition for Ajp13 worker

For each virtual host, you will need to give Apache several mod_jk configuration directives as listed here This step is covered at the end of this article.

Modify Tomcat's Startup Script /bin/

You can set the JAVA_HOME and CATALINA_HOME as environment variables if you like. Otherwise, you can set them directly in the file for Tomcat to pick up.
Of course you need to set these values to the version and the path that you used for both Java and Tomcat.


Modify Tomcat's Config file /conf/server.xml

In this step, you can configure one or more domains under Plesk to serve a JSP webapp. Although this process is done by hand, you can configure scripts to modify this file when a new domain is added.

To add a webapp for a domain, you need to add a new host declaration.

Find the default virtual host:

      <!-- Define the default virtual host
           Note: XML Schema validation will not work with Xerces 2.2.
      <Host name="localhost" appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">

and add a new virtual host:

      <Host name="" debug="0" appBase="/home/httpd/vhosts/"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">

Create a directory /home/httpd/vhosts/ for each virtual host's webapp.

Change ownership of this directory so that Tomcat can work with the files chown tomcat5:tomcat5 /home/httpd/vhosts/

And finally, for each virtual host that you define, you will need to modify the vhost.conf file to have Apache play nice with Tomcat. This step gives Apache the mod_jk configuration directives for your virtual host.

Restart Tomcat
You should now be ready to restart Apache and Tomcat

/etc/init.d/httpd restart
/etc/init.d/tomcat5 restart

Try connecting to one of your virtual hosts, and if this does not work, try using port 8080 If port 8080 is working, there is a problem with Apache talking to Tomcat and you will need to check your mod_jk settings.

If all is working, try restarting your server to make sure the startup script works and Tomcat runs on startup. Nobody likes webserver downtime!

Some things to consider
This upgrade does break the Plesk / Tomcat relationship. If you have customers with their own domains, you may want to take additional steps such as defining the security policy for Tomcat, automating the addition of virtual hosts to server.xml, and exposing the Tomcat manager to each virtual host client so they can deploy .war files on their own.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.