Server Rebuild - Railo on Tomcat with Apache

Jan 12 2010

Server Rebuild - Railo on Tomcat with Apache

Posted by AJ Mercer at 10:08 PM Railo | Webonix

I have decided to go with Apache and Tomcat for my Railo server, and so today rebulit the server from scratch. The server is still running Ubuntu 9.10 and I did a LAMP install.

Next I used Viviotech Railo installer - thanks Jordan. This installs Tomcat and Railo and then hooks it up to Apache (using mod_jk). Thanks also to the great people on the Railo list for helping me with Apache and Tomcat configurations for rewrite rules and Aliases.

For the records

Apache site config

<VirtualHost *:80>
    ServerAdmin admin@webonix.net
    ServerName    webonix.net
    ServerAlias    www.webonix.net

    DocumentRoot /path/to/webroot/
    DirectoryIndex index.cfm index.html

    RewriteEngine On
    RewriteCond %{HTTP_HOST} www\.webonix\.net [NC]
    RewriteCond %{HTTP_HOST} !^$
    RewriteRule ^/(.*) http://webonix.net/$1 [L,R]
    RewriteRule ^/post/(.*)$ /post.cfm/$1 [L,PT,QSA]
    RewriteRule ^/archives/(.*)/(.*)/(.*)$ /archives.cfm/$1/$2/$3 [L,PT,QSA]
    RewriteRule ^/archives/(.*)/(.*)$ /archives.cfm/$1/$2 [L,PT,QSA]
    RewriteRule ^/archives/(.*)$ /archives.cfm/$1 [L,PT,QSA]
    RewriteRule ^/page/(.*)$ /page.cfm/$1 [L,PT,QSA]
    RewriteRule ^/author/(.*)$ /author.cfm/$1 [L,PT,QSA]   
    RewriteRule ^/feeds/(.*)$ /feeds/$1.cfm [L,PT,QSA]
</VirtualHost>

/webroot/WEB-INF/web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    version="2.5">
    <!-- The mapping for the Railo servlet -->
    <servlet-mapping>
        <servlet-name>CFMLServlet</servlet-name>
        <url-pattern>/post.cfm/*</url-pattern>
        <url-pattern>/archives.cfm/*</url-pattern>
        <url-pattern>/page.cfm/*</url-pattern>
        <url-pattern>/author.cfm/*</url-pattern>
    </servlet-mapping>
</web-app>

tomcat server.xml

<Host name="webonix.net"
      appBase="webapps"
      unpackWARs="true"
      autoDeploy="true"
      xmlValidation="false"
      xmlNamespaceAware="false">
      <Context path="" docBase="/path/to/webroot" />
</Host>

tomcat web.xml

<!-- The mapping for the Railo servlet -->
<servlet-mapping>
    <servlet-name>CFMLServlet</servlet-name>
    <url-pattern>*.cfm</url-pattern>
    <url-pattern>*.cfml</url-pattern>
    <url-pattern>*.cfc</url-pattern>
</servlet-mapping>