install-tomcat

OrderlyStats SE - Installation

This page describes the installation process of Tomcat

FREE INSTALLATION SUPPORT is available for OrderlyStats - so if you get stuck just give us a call or, write in .

Although some distributions have a Tomcat package available, we have found these tricky to install and configure, and prone to upgrade problems.

You're better off downloading Tomcat directly from the Apache Software Foundation at http://tomcat.apache.org. Choose the latest Binary Distribution, or use this direct link (right-click to save).

You will need version 7.0.27 or above in order to use WebSockets for the live Control Panel feed (recommended).

Once you've got the file, unpack it with: tar -xvzf apache-tomcat-7.0.35.tar.gzThis will create a new folder containing Tomcat.

Next, move Tomcat to a more convenient location with: mv apache-tomcat-7.0.35 /usr/share/orderly/tomcatThis will be your CATALINA_HOME. You may find it easiest to save this as an environment variable while you're doing the rest of the installation by running:

export CATALINA_HOME=/usr/share/orderly/tomcat

Now we need to create a script to start and stop Tomcat. Create a new file with: nano /etc/init.d/orderlystatsse and paste in the following cross-distribution startup script (or download it here):

#!/bin/bash
#
# Startup script for the Tomcat server
#
# chkconfig: - 83 53
# description: Starts and stops the Tomcat daemon.
# processname: tomcat
# pidfile: /var/run/tomcat.pid

export JAVA_HOME=/usr/share/orderly/java #You may need to edit this line
export CATALINA_HOME=/usr/share/orderly/tomcat #You may need to edit this line
export CATALINA_OPTS="-Xmx256M"
export CATALINA_PID=/var/run/tomcat.pid
export NICENESS=10

#See how we were called.
case $1 in
 start)
   sh $CATALINA_HOME/bin/shutdown.sh -force
   nice -n $NICENESS $CATALINA_HOME/bin/startup.sh
  ;;
  stop)
   sh $CATALINA_HOME/bin/shutdown.sh -force
  ;;
  restart)
   sh $CATALINA_HOME/bin/shutdown.sh -force
   nice -n $NICENESS $CATALINA_HOME/bin/startup.sh
  ;;
  *)
   echo "Usage: /etc/init.d/orderlystatsse start|stop|restart"
  ;;
esac

exit 0

If you used a different location for your JAVA_HOME or CATALINA_HOME directories, you will need to edit the lines indicated.

Save the file and exit, and make it executable with: chmod 755 /etc/init.d/orderlystatsse

Now, try starting tomcat with: /etc/init.d/orderlystatsse start

If tomcat has started correctly, you should be able to see it running with: ps -ef | grep java

NOTE: By default Tomcat listens for web requests on port 8080. On some distributions the default port is 8180. You can change the port by editing $CATALINA_HOME/conf/server.xml

NOTE: If your OrderlyStats server is running behind a firewall, you will need to allow traffic on port 8080, and also port 8081 (which is used for the Realtime Control Panel and Agent Bar).

NOTE: If you want OrderlyStats to start automatically whenever your server is rebooted, you will have to add startup links that point to /etc/init.d/orderlystatsse to achieve this (usually in /etc/rc2.d). You should make sure tomcat is started after your database. Please see your linux distribution documentation for further details.

For best results, it's a good idea to restart tomcat each night when your call centre is closed. To do this, create a script with: nano /etc/cron.daily/tomcat

Copy and paste in the following:

#!/bin/sh

test -x /etc/init.d/orderlystatsse || exit 0
/etc/init.d/orderlystatsse stop >/dev/null 2>&1
sleep 10
/etc/init.d/orderlystatsse start >/dev/null 2>&1

You also need to make this script executable with: chmod 755 /etc/cron.daily/tomcat

As a final test, make sure you can see the Tomcat default home page by opening a browser window, and accessing http://my.ip.address:8080/