Running Lenya 2 in Jetty 6 with Apache 2

While the standalone build of Lenya is good to get started with, it's not really good enough for most production uses. This how-to explains how you can set up Lenya under a more typical production configuration, using Jetty 6 and Apache 2. The example commands are from Debian-style Linux distros; replace with your own if you're not on one.

1. Set up the environment

  1. Install Java 6 JDK from Sun. OpenJDK isn't fully compatible with Batik, the image processing library used in Lenya:
    • # aptitude install sun-java6-jdk
  2. Install Jetty:
    • # aptitude install jetty
  3. Install Apache 2:
    • # aptitude install apache2
  4. Make sun-java your default JVM:
    • Go to JAVA_HOME, e.g. /usr/lib/jvm and # ln -s java-6-sun default-java
  5. Test run Jetty.
    • # /etc/init.d/jetty start

...and surf to localhost:8080 (or whichever port Jetty is set to run on; some default installs have it at 8280).

Note: I had a problem with a misconfiguration out of the box; I had to comment out the line /etc/jetty/jetty-shared-webapps.xml in /usr/share/jetty/etc/jetty.conf. YMMV.

2. Set up Lenya

  1. Build Lenya as per the instructions. Standalone or .war, doesn't matter.
  2. Put lenya.war or [LENYA_SRC]/build/lenya/webapp under [JETTY_HOME]/webapps (rename webapp to lenya).
  3. Copy or link [LENYA_SRC]/externals/cocoon_2_1_x/lib/endorsed/jakarta-regexp-1.5.jar under [JETTY_HOME]/lib/ext (or put it elsewhere on your classpath).

Start Jetty and surf to http://locahost:8080/lenya/. You should see the Lenya homepage.

3. Set up the proxy directives:

  1. Enable mod_proxy and mod_proxy_http in Apache. For example, go to /etc/apache2/mods-enabled, and symlink to ../mods-available/proxy.load, ../mods-available proxy.conf, and ../mods-available/proxy_http.load.
  2. Add your proxy confs to /etc/apache2/mods-available/proxy.conf.

Note: There are lots and lots of ways to set up apache2; this is sort of the simplest case. Check the httpd documentation for more.

Mine looks something like this (replace YOURPUB with your publication, naturally):

<IfModule mod_proxy.c>

# Turn off support for true Proxy behaviour as we are acting as
# a transparent proxy

ProxyRequests Off

# Turn off VIA header as we know where the requests are proxied

ProxyVia Off

# Turn on Host header preservation so that the servlet container
# can write links with the correct host and rewriting can be avoided.

ProxyPreserveHost On

# Set the permissions for the proxy

<Proxy *>
  AddDefaultCharset off
  Order deny,allow
  Allow from all
</Proxy>

# Turn on Proxy status reporting at /status
# This should be better protected than: Allow from all

ProxyStatus On

<Location /status>
  SetHandler server-status
  Order Deny,Allow
  Allow from all
</Location>

# Make the domain root go to the 'live' area of the YOURPUB publication
ProxyPass '' http://localhost:8080/lenya/YOURPUB/live

# Find the base resources used for authoring
ProxyPass /lenya http://localhost:8080/lenya

# Shorten the URL for authoring
ProxyPass /authoring http://localhost:8080/lenya/YOURPUB/authoring

# Lenya sets a session cookie for /lenya, but we need it at /
ProxyPassReverseCookiePath /lenya /

</IfModule>

Note the ProxyPassReverseCookiePath directive -- you need one if you mess with the URI paths as above.

3. Configure your publication for these proxies

Edit [YOURPUB_HOME]/config/publication.xml and add the following to the <proxies> node:

<proxy area="live" ssl="false" url=""/>
<proxy area="authoring" ssl="false" url="/authoring"/>

You can also use full URL's, including the scheme and the domain, for the url attributes.

And that's about it.

HowToJettyInstall (last edited 2010-02-22 18:09:45 by PetteriSulonen)