{docbook}
<abstract>
<para>
This chapter covers the following topics:
</para>
<itemizedlist>
<listitem>
<para>
<emphasis role="bold"><link linkend="ADM.Deployment.How_to_remove_sample_application">Remove sample applications</link></emphasis>
</para>
<para>
Steps to remove a sample portal (Acme website/Acme Social Intranet) and a crash.
</para>
</listitem>
<listitem>
<para>
<emphasis role="bold"><link linkend="ADM.Deployment.Deploy_custom_extension">Deploy a custom extension</link></emphasis>
</para>
<para>
Brief information which you need to concern when deploying a custom extension.
</para>
</listitem>
<listitem>
<para>
<emphasis role="bold"><link linkend="ADM.Deployment.Setup_Apache_Frontend">Set up Apache front-end</link></emphasis>
</para>
<para>
Introduction to the base configuration for Apache, and methods to "glue" Apache HTTP Daemon and Tomcat application server.
</para>
</listitem>
<listitem>
<para>
<emphasis role="bold"><link linkend="ADM.Deployment.Configure_session_time-out_for_web_server">Configure the session timeout for the web server</link> </emphasis>
</para>
<para>
Instructions on how to configure the session timeout of the Tomcat and Jboss servers.
</para>
</listitem>
</itemizedlist>
</abstract>
{docbook}

h1. Remove sample applications {anchor:id=ADM.Deployment.How_to_remove_sample_application}

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.

{docbook}
<para xml:id="ADM.Deployment.Remove_Acme_SocialIntranet">
<citetitle>
<emphasis role="bold">
Remove Acme website/Acme Social Intranet
</emphasis>
</citetitle>
</para>
{docbook}

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

*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.

{docbook}
<para xml:id="ADM.Deployment.Remove_crash">
<citetitle>
<emphasis role="bold">
Remove a Crash
</emphasis>
</citetitle>
</para>
{docbook}

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_.

*1.* Stop the serve by using the _shutdown.sh_ command.

*2.* Delete the _crash.war_ file.

*3.* Restart the server.

{docbook}
<para>
<prompt>
  <emphasis role="bold">See also</emphasis>
</prompt>
</para>
{docbook}
* [Deploy a custom extension|#ADM.Deployment.Deploy_custom_extension]
* [Set up Apache front-end|#ADM.Deployment.Setup_Apache_Frontend]
* [Configure the session timeout for the web server|#ADM.Deployment.Configure_session_time-out_for_web_server]

h1. Deploy a custom extension {anchor:id=ADM.Deployment.Deploy_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|http://tomcat.apache.org/tomcat-6.0-doc/deployer-howto.html#A_word_on_Contexts].

{docbook}
<para>
<prompt>
  <emphasis role="bold">See also</emphasis>
</prompt>
</para>
{docbook}
* [Remove sample applications|#ADM.Deployment.How_to_remove_sample_application]
* [Set up Apache front-end|#ADM.Deployment.Setup_Apache_Frontend]
* [Configure the session timeout for the web server|#ADM.Deployment.Configure_session_time-out_for_web_server]

h1. Set up Apache front-end {anchor:id=ADM.Deployment.Setup_Apache_Frontend}

{docbook}
<highlights>
	<itemizedlist>
	  <listitem>
		<para>
		  <link linkend="ADM.Deployment.Connection_via_HTTP_protocol">Connect via HTTP protocol</link>
		</para>
	  </listitem>
	  <listitem>
		<para>
		  <link linkend="ADM.Deployment.Connection_via_AJP_protocol">Connect via AJP protocol</link>
		</para>
	  </listitem>
	</itemizedlist>
</highlights>
{docbook}

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|http://httpd.apache.org/docs/2.2/mod/mod_proxy.html].

- via the [Apache JServ Protocol|http://tomcat.apache.org/connectors-doc/ajp/ajpv13a.html] using [Tomcat connector|http://tomcat.apache.org/connectors-doc/] or [HTTPD AJP proxy module|http://httpd.apache.org/docs/2.2/mod/mod_proxy_ajp.html].

{docbook}
<para xml:id="ADM.Deployment.Base_Configuration_for_Apache">
<citetitle>
<emphasis role="bold">
Base configuration for Apache
</emphasis>
</citetitle>
</para>
{docbook}

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:

{code}<VirtualHost *:80>
  ServerName      Enter your server DNS name here
  RedirectMatch permanent "^/?$" "/portal/"
</VirtualHost>{code}
You can find more information on the Apache HTTP daemon host [here|http://httpd.apache.org/docs/2.2/vhosts/].

{docbook}
<para>
<prompt>
  <emphasis role="bold">See also</emphasis>
</prompt>
</para>
{docbook}
* [Remove sample applications|#ADM.Deployment.How_to_remove_sample_application]
* [Deploy a custom extension|#ADM.Deployment.Deploy_custom_extension]
* [Configure the session timeout for the web server|#ADM.Deployment.Configure_session_time-out_for_web_server]

h2. Connect via HTTP protocol (Apache mod{{{_}}}proxy) {anchor:id=ADM.Deployment.Connection_via_HTTP_protocolRoleNotInToc}

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.

{code}ProxyRequests   Off
ProxyPass	 "/" http://YOUR_AS_HOST:AS_HTTP_PORT/
ProxyPassReverse "/" http://YOUR_AS_HOST:AS_HTTP_PORT/{code}

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:
{code}<VirtualHost *:80>
  ServerName      Enter your server DNS name here
  RedirectMatch	permanent "^/?$" "/portal/"
  ProxyRequests   Off
  ProxyPass	 "/" http://localhost:8080/
  ProxyPassReverse "/" http://localhost:8080/
</VirtualHost>{code}
For more detail on *mod{{{_}}}proxy*, refer to this [documentation|http://httpd.apache.org/docs/2.2/mod/mod_proxy.html].

h2. Connect via AJP protocol {anchor:id=ADM.Deployment.Connection_via_AJP_protocolRoleNotInToc}

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|http://httpd.apache.org/docs/2.2/mod/mod_proxy_ajp.html].

* *The second way:* Use the native Apache Tomcat's [AJP connector|http://tomcat.apache.org/connectors-doc/ajp/ajpv13a.html].

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.

{docbook}
<para xml:id="ADM.Deployment.AJP_proxy_module">
<citetitle>
<emphasis role="bold">
AJP proxy module
</emphasis>
</citetitle>
</para>
{docbook}

Make sure that _mod\_proxy\_ajp.so_ is included in the list of loadable modules.
Add the following to your virtual host configuration setting:

{code}ProxyPass / ajp://localhost:8009/{code}

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:
{code}<VirtualHost *:80>
  ServerName      Enter your server DNS name here
  RedirectMatch	permanent "^/?$" "/portal/"
  ProxyRequests   Off
  ProxyPass	/ ajp://localhost:8009/
</VirtualHost>{code}

{docbook}
<para xml:id="ADM.Deployment.Apache_Tomcat's_AJP_connector">
<citetitle>
<emphasis role="bold">
Apache Tomcat's AJP connector
</emphasis>
</citetitle>
</para>
{docbook}

*1.* Download AJP connector module [here|http://apache.vc.ukrtel.net/tomcat/tomcat-connectors/jk/binaries/].

*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.

{code}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>{code}

For more details, see the [Tomcat documentation|http://tomcat.apache.org/connectors-doc/reference/apache.html].

*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|http://tomcat.apache.org/connectors-doc/generic_howto/workers.html] for the HTTP daemon.

{code}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{code}

{note}
In the example above, you can change _WORKER\_NAME_ to any value.
{note}

*6.* Put this file in the same directory as the _mod\_jk.conf_ file.

*7.* Update the virtual host configuration.

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

h1. Configure the session timeout for the web server {anchor:id=ADM.Deployment.Configure_session_time-out_for_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:

{code:xml}<!-- ==================== 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>{code}

{docbook}
<para xml:id="ADM.Deployment.TomcatJBossServer">
<citetitle>
<emphasis role="bold">
Configure the session timeout of the Tomcat and JBoss servers
</emphasis>
</citetitle>
</para>
{docbook}

*1.* Stop the server by the _shutdown.sh_ command.

*2.* Open the _web.xml_ file.

*Files location*

||File||Tomcat||JBoss||
|_*web.xml*_|_$PLATFORM\_TOMCAT\_HOME/conf/web.xml_|_$Jboss\_home/server/default/deployers/jbossweb.deployer/web.xml_|

*3.* Change the value of the session-timeout.

*4.* Save and then restart the server by the _gatein.sh_ command.

{docbook}
<para>
<prompt>
  <emphasis role="bold">See also</emphasis>
</prompt>
</para>
{docbook}
* [Remove sample applications|#ADM.Deployment.How_to_remove_sample_application]
* [Deploy a custom extension|#ADM.Deployment.Deploy_custom_extension]
* [Set up Apache front-end|#ADM.Deployment.Setup_Apache_Frontend]