2.3. Tomcat and Apache configuration

OLAT runs in a standard J2EE servlet container as a webapplication. There is no need for EJB support. We suggest using the official servlet container reference implementation Apache Tomcat. Tomcat is available for free under an Open Source license.

Although you can use any other servlet container implementation we recommend using Tomcat since OLAT has been in production using the Tomcat servlet container for quite some time now. If you decide to use another container, please send us your installation instructions and any tip or trick that could help installing OLAT - we will include it into this manual.

During installation some example configuration files have been generated.

#cd PATH_TO_YOUR_OLAT/olat/conf/
#ls
apachelogrotate		apachelogrotate.in
httpd.conf			httpd.conf.in
httpd.conf.out		mod_jk-1.3.26.dll
server.xml
server.xml.in

If you have no server.xml and httpd.conf in this directory you need to generate them first. Make sure your build.properties file has the correct values. Copy the default property file if you haven't done this so far.

#cd PATH_TO_YOUR_OLAT/olat3/
#cp build.properties.default build.properties
#vi build.properties
#ant config-all

Standalone: Tomcat using the HTTP connector

When installing OLAT the first time we recommend to install it first only using Tomcat with the httpd connector to reduce complexity. When everything works fine you can then proceed installing the server.xml that uses the JK connector.

Copy the PATH_TO_YOUR_OLAT/olat3/conf/server.xml to your tomcat installation.

#cp PATH_TO_YOUR_OLAT/olat3/conf/server.xml PATH_TO_TOMCAT/conf/server.xml

In most cases the generated file works out of the box, if not look at the file and do some tweaking.

Restart Tomcat

Combined: Tomcat and Apache using the JK connector

For a production server it is recomended to use apache as a gate keeper in front of tomcat. This is for many reasons, mainly security issues, better support for virtual hosts, ssl, standard tools for log analyzing, availability of douzens of usefull plugins for apache like redirect, throttle etc.

There are two connectors: JK and JK2. JK2 is not in development anymore, the examples are all for the JK connector.

There are two versions of Apache: 1.3.x and 2.x. For some time now we use Apache 2.x. All examples are for Apache 2.x, however the http configuration file should also work with a 1.3.x installation.

You must configure the server.modjk.enabled=true property in your build.properties. Then run ant config-all to generate all the config files.

Copy the PATH_TO_YOUR_OLAT/olat3/conf/server.xml to your server tomcat installation

#cp PATH_TO_YOUR_OLAT/olat3/conf/server.xml PATH_TO_TOMCAT/conf/server.xml

In most cases the generated file works out of the box, if not look at the file and do some tweaking.

Restart Tomcat

Copy the PATH_TO_YOUR_OLAT/olat3/conf/httpd.conf to your apache installation.

#cp PATH_TO_YOUR_OLAT/olat3/conf/httpd.conf PATH_TO_YOUR_APACHE_CONFIG_FILES/vhost_olat.conf

Now you need to include this virtual host in your apache installation. This is different on every unix platform so we can't give you any advice here. In most cases the generated file works out of the box, if not look at the file and do some tweaking.

The generated httpd.conf references to PATH_TO_YOUR_OLAT/olat3/conf/workers.properties. In most cases the generated file works out of the box, if not look at the file and do some tweaking.

Tip

The <IfModule mod_jk.c> section in the generated httpd.conf file must be outside the virtual host definition. Only one workers file can be included for the whole Apache installation. If you want to run multiple virtual hosts you need to define multiple mount points, for each virtual host one.

If you need SSL support add another virtual host based on the generated httpd.conf file.

Restart Apache.

Make sure that you installed the Apache Portable Runtime (APR) to make the JK connection stable! See the Apache documentation for more information. If in your intallation images or CSS files are not delivered correctly it could be due to the missing APR module.

MacOS X

Under MacOS X the Apache configuration is quite different than it is on a Linux system. Robert Frank from Univerisity of Basel contributed a setup generator script that generates the necessary files. Thank you Frank!

You will find the script at PATH_TO_YOUR_OLAT/olat3/bin/MacOSXOlatSetupGeneraror.pl

Tomcat VM parameters and Operating System issues

The following virtual machine parameters should be used when starting tomcat:

  • -Xss256k: specify the stack size. Default is 0.5 MB which is way to much and consumes a lot of virtual memory. This is the memory used for each thread. If you have the Instant Messaging component enabled for every logged in user four threads will be created which can result in a very high memory usage. Please note that this is stack memory and is consumed in addition to the memory you specify with the -Xms and -Xmx flags!

  • -Xms2688m -Xmx2688m: specify the amount of memory tomcat can use as a maximum. This is the amount configured at University of Zurich (August 2008). Bigger values mean also longer full garbage collection times, which may then lead to congestion. If your memory becomes a bottleneck you should consider as a first step to install an instance dedicated to full text search, indexing. OLAT 6.1.x (Spring 2009) will bring the possibility to run olat in cluster mode.

  • -Djava.awt.headless=trueIf you run OLAT on a Unix/Linux box with no graphics environment started (e.g. KDE, Gnome) classes using image frame buffers will not work and throw an exception. By enabling the headless mode the jvm emulates an graphics environment.

Example configuration for the tomcat5/bin/catalina.sh file which includes also some garbage collection tweaks that are optional but may help if you have a lot of memory assigned.

CATALINA_OPTS="-server -Xss256k -Xms3073m -Xmx3073m -Djava.net.preferIPv4Stack=true -Djava.awt.headless=true -Xloggc:/tmp/gc.log -XX:+PrintGCDetails -XX:+PrintGCTi
meStamps -XX:PermSize=100m"
        

The following is no longer relevant for OLAT > 4.0.0, but is still an issue if you run OLAT 3.2.x or if you run a very large OLAT installation

When you have the course logging enabled in the olat_config.xml file every course has at least three permanent opened filehandel. If your system is not configured propertly your Java VM can get very easily in too many opend files-condition. Unfortunately the standard configuration in Linux is to allow each process to have only 1024 opend files. Change this setting to a value that fits your needs. You can test your limits using the following commands:

#count open files for a certain process
lsof -p [process-id] | wc -l
 
ulimit -Ha
ulimit -Sa

See the manual of your operating system how to change this values