## 2.4. 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_http_connector.xml.out		wildfire.xml
    server.xml.in					server_jk_connector.xml				wildfire.xml.in
    server_http_connector.xml		server_jk_connector.xml				wildfire.xml.in

If you have no server_http_connector.xml, server_jk_connector.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

### 2.4.1. 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

### 2.4.2. 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.

Copy the PATH_TO_YOUR_OLAT/olat3/conf/server_jk_connector.xml to your server tomcat installation, rename it server.xml

    #cp PATH_TO_YOUR_OLAT/olat3/conf/server_jk_connector.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.

#### 2.4.2.1. 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

### 2.4.3. 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 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!

- -Xms768m -Xmx768m: specify the amount of memory tomcat can use as a maximum. With about 200 concurrent users (Userbase 7500 users) OLAT usually requires about 300 MB. This configuration example is for a very large site. Note that in addition to the memory specified here the VM uses for every thread an additional amount of memory specified by the -Xss option.

- -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 from the tomcat5/bin/catalina.sh file:

    CATALINA_OPTS="-server -Xss256k -Xms768m -Xmx768m -Djava.net.preferIPv4Stack=true -Djava.awt.headless=true"

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

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