eXo Platform 3.5

## Chapter 7. Deployment

This chapter covers the following topics:

- Remove sample applications

- Deploy a custom extension

- Set up Apache front-end

- Configure the session timeout for the web server

## 7.1. Remove sample portals

eXo Platform comes with two sample portals that show the capabilities of the product. However, once implementing your own extensions, you may not need these sample portals. In some cases, you usually want to remove them before deploying your system in production.

The following instructions are used in cases where the hsqldb embedded database configuration is used.

### 7.1.1. Remove Acme website/Acme Social Intranet

Both Acme website and Acme Social Intranet are sample extensions demonstrating the intranet that you can implement with eXo Platform.

Remove the Acme website/Acme Social Intranet

1. Stop the server using the shutdown.sh command.

2. Delete the following relevant files: Tomcat

- For the Acme website: webapps/acme-website.war, lib/exo.platform.sample.acme-website.config.jar, Tomcat/conf/Catalina/localhost/acme-website.xml and gatein/data.

- For the Acme Social Intranet: webapps/acme-intranet.war, lib/exo.platform.sample.acme-intranet.config.jar, Tomcat/conf/Catalina/localhost/acme-intranet.xml and gatein/data.

JBoss

- For the Acme website: server/default/deploy/exo-acme-website-3.5.1.ear.

- For the Acme Social Intranet: server/default/deploy/exo-social-intranet-3.5.1.ear.

3. Restart the server.

### 7.1.2. Remove Crash

Crash is a complementary tool for development and maintenance. As it opens telnet and SSH sockets, it is highly recommended that you remove Crash for your production deployments. Crash is in the crash.war file in tomcat/webapps.

Remove a Crash

1. Stop the serve by using the shutdown.sh command.

2. Delete the crash.war file.

3. Restart the server.

## 7.2. Deploy a custom extension

Extensions are packaged as the Java EE web applications and packaged as the normal .war files. To deploy the custom extension, you may do as for any other web apps.

In Tomcat, this ends up by copying the war archive to the webapps folder.

However, the GateIn extension mechanism imposes that the starter.war webapp starts after all extension wars.

This is the case for the sample applications bundled by default.

There are several ways to control the loading order of webapps in Tomcat. Please refer to Tomcat's Deployer How To.

## 7.3. Set up Apache front-end

It may be necessary to use the HTTP server as a front-end for Tomcat. For example, you may want to keep more than one application server on the same host, and/or you want to access these app servers with the separate DNS names, without adding a port to the URL.

There are two methods that allow you to "glue" Apache HTTP Daemon and Tomcat application server:

- via the HTTP protocol using proxy module.

- via the Apache JServ Protocol using Tomcat connector or HTTPD AJP proxy module.

### 7.3.1. Base configuration for Apache

First, you need to configure a new virtual host in Apache HTTPD for the application server. This is the simplest example of a virtual host:

    <VirtualHost *:80>
      ServerName      Enter your server DNS name here
      RedirectMatch permanent "^/?$" "/portal/"
    </VirtualHost>

You can find more information on the Apache HTTP daemon host here.

### 7.3.2. Connect via HTTP protocol (Apache mod_proxy)

With the glue method, it is necessary to configure the Apache HTTP daemon to work as the reverse proxy, which will redirect the client's requests to the app server's HTTP connector.

For this connection type, you need to include the mod_proxy module in the HTTP daemon configuration file. This can be found in the httpd.conf file, which is usually located at /etc/httpd/conf/. However, depending on your OS, this path may vary. You will then need to add some directives to your virtual host configuration.

    ProxyRequests   Off
    ProxyPass	 "/" http://YOUR_AS_HOST:AS_HTTP_PORT/
    ProxyPassReverse "/" http://YOUR_AS_HOST:AS_HTTP_PORT/

Details:

- YOUR_AS_HOST - host (IP or DNS name) is the location of your application server. If you run the HTTP daemon on the same host as your app server, you can change this to localhost.

- AS_HTTP_PORT - port is the location where your app server will listen to incoming requests. For Tomcat, this value is 8080 by default. You can find the value at tomcat/conf/server.xml.

In the above example, the HTTP daemon will work in the reverse proxy mode (ProxyRequests Off) and will redirect all requests to the tcp port 8080 on the localhost. So, the configuration of a virtual host looks like the following:

    <VirtualHost *:80>
      ServerName      Enter your server DNS name here
      RedirectMatch	permanent "^/?$" "/portal/"
      ProxyRequests   Off
      ProxyPass	 "/" http://localhost:8080/
      ProxyPassReverse "/" http://localhost:8080/
    </VirtualHost>

For more detail on mod_proxy, refer to this documentation.

### 7.3.3. Connect via AJP protocol

As described above, the 'glue' method can be implemented via one of the following ways:

- The first way: Use the native Apache HTTP Daemon's AJP proxy module.

- The second way: Use the native Apache Tomcat's AJP connector.

With the first method, you only need the HTTP daemon and application server, but settings are limited.

With the second method, you can obtain more settings, but you will need to download and install additional modules for the HTTP Daemon that are not included in the default package.

#### AJP proxy module

Make sure that mod_proxy_ajp.so is included in the list of loadable modules. Add the following to your virtual host configuration setting:

    ProxyPass / ajp://localhost:8009/

In this example, the app server is located on the same host as the Apache HTTP daemon, and accepts incoming connections on the port 8009 (the default setting for the Tomcat application server). You can find the full list of virtual host configurations here:

    <VirtualHost *:80>
      ServerName      Enter your server DNS name here
      RedirectMatch	permanent "^/?$" "/portal/"
      ProxyRequests   Off
      ProxyPass	/ ajp://localhost:8009/
    </VirtualHost>

#### Apache Tomcat's AJP connector

1. Download AJP connector module here.

2. Move the downloaded mod_jk.so file to the HTTPD's module directory, for example /etc/httpd/modules. The directory may be different, depending on the OS.

3. Create the configuration file for the mod_jk.conf module.

    LoadModule    jk_module  modules/mod_jk.so
    <IfModule jk_module>
      # ---- Where to find workers.properties
            JkWorkersFile   conf.d/workers.properties
      # ---- Where to put jk logs
      JkLogFile       logs/mod_jk.log
      # ---- Set the jk log level [debug/error/info]
      JkLogLevel    info
      # ---- Select the timestamp log format
      JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
      JkRequestLogFormat "%w %R %T"
      # ---- Send everything for context /examples to worker named worker1 (ajp13)
      JkMountFileReload       "0"
    </IfModule>

For more details, see the Tomcat documentation.

4. Place the mod_jk.conf file into the directory where other configuration files for Apache HTTP daemon are located. For example, /etc/httpd/conf.d/.

5. Create the workers.properties file, which defines the AJP workers for the HTTP daemon.

    worker.list=status, WORKER_NAME
    # Main status worker
    worker.stat.type=status
    worker.stat.read_only=true
    worker.stat.user=admin
    # Your AJP worker configuration
    worker.WORKER_NAME.type=ajp13
    worker.WORKER_NAME.host=localhost
    worker.WORKER_NAME.port=8109
    worker.WORKER_NAME.socket_timeout=120
    worker.WORKER_NAME.socket_keepalive=true

### Note

In the example above, you can change WORKER_NAME to any value.

6. Put this file in the same directory as the mod_jk.conf file.

7. Update the virtual host configuration.

    <VirtualHost *:80>
      ServerName      Enter your server DNS name here
      RedirectMatch	permanent "^/?$" "/portal/"
      ProxyRequests   Off
      JkMount         /*	WORKER_NAME
    </VirtualHost>

## 7.4. Configure the session timeout for the web server

The session timeout defines the validation period of a session. In the portal environment, such as eXo Platform, it is highly recommended that all web applications have the same session timeout value.

The session timeout is configurable individually for each web application in the web.xml file:

    <!-- ==================== Default Session Configuration ================= -->

    <!-- You can set the default session timeout (in minutes) for all newly   -->

    <!-- created sessions by modifying the value below.                       -->

    <session-config>

      <session-timeout>30</session-timeout>

    </session-config>

### 7.4.1. Tomcat server

In the Tomcat bundle, this file is located at $TOMCAT_HOME/conf/web.xml.

Configure the session timeout of Server Tomcat

1. Stop the server by the shutdown.sh command.

2. Open the web.xml file.

3. Change the value of the session-timeout.

4. Save and then restart the server by the gatein.sh command.

### 7.4.2. JBoss server

In the JBoss server, this file is located at $Jboss_home/server/default/deployers/jbossweb.deployer/web.xml.

Configure the session timeout of the JBoss server

1. Stop the server by using the shutdown.sh command.

2. Open the web.xml file.

3. Change the value of the session timeout.

4. Save and restart the server.

Copyright © 2009-2012. All rights reserved. eXo Platform SAS