Updated: Changed the linking between railo and tomcat to use shared.loader.
I've been doing some more work on configuring railo to work flexibly in the numerous different environments we work in, and also making it simpler to set up.
To that end I investigated the use of mod_proxy for linking it to apache instead of mod_jk.
Advantages of this approach are:
- Simple - communications are in plain http
- Flexible - Load balancing can be easily added at the apache layer
- Simple - No compiling mod_jk
Here are the basic install instructions for Railo/Tomcat/Apache on Ubuntu.
Download & Install Tomcat
Download tomcat and extract content:
tar xvzf apache-tomcat-6.0.26.tar.gz
Move Tomcat to a more appropriate place:
sudo mv apache-tomcat-6.0.26 /opt/tomcat
Download Railo
Download Railo custom version jars file
Extract and move into Tomcat lib directory:
tar zxvf railo-3.1.2.001-jars.tar.gz
sudo mv railo-3.1.2.001-jars /opt/railo
Make Tomcat load the railo jars by editing catalina.properties to change the shared loader path:
shared.loader=/opt/railo/*.jar
Make Tomcat and Railo work together by modifying the web config file:
sudo nano -w /opt/tomcat/conf/web.xml
add the following inside the <web-app> element:
<servlet>
<servlet-name>CFMLServlet</servlet-name>
<servlet-class>railo.loader.servlet.CFMLServlet</servlet-class>
<init-param>
<param-name>configuration</param-name>
<param-value>{web-root-directory}/WEB-INF/railo/</param-value>
<description>Configuraton directory</description>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CFMLServlet</servlet-name>
<url-pattern>*.cfm</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>CFMLServlet</servlet-name>
<url-pattern>*.cfml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>CFMLServlet</servlet-name>
<url-pattern>*.cfc</url-pattern>
</servlet-mapping>
add the following inside <welcome-file-list> element:
<welcome-file>index.cfm</welcome-file>
<welcome-file>index.cfml</welcome-file>
Start up tomcat:
/opt/tomcat/bin/startup.sh
Once this is done you should be able to access the railo admin by going to the following URL:
Back to Tomcat
To test our Railo installation, let's create a test site by adding a new virtual host in both Tomcat and Apache. We do this by modifying Tomcat server.xml file (/opt/tomcat/conf/server.xml )
<Host name="testsite.railo" appBase="webapps">
<Context path="" docBase="/vhosts/testsite.railo/www"/>
</Host>
Linking with Apache via Mod Proxy
Ensure the modules proxy and proxy_http are enabled. On Ubuntu this is done as follows:
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo /etc/init.d/apache2 restart
Create vhost
Now we need to create a virtual host entry in Apache as well:
<VirtualHost *:80> DocumentRoot /vhosts/testsite.railo/www
ServerName testsite.railo
DirectoryIndex index.cfm
#Proxy .cfm requests to railo
<IfModule mod_proxy.c> <Proxy *> Order deny,allow
Allow from all
</Proxy> ProxyPassMatch ^/(.*\.cfm)$
http://testsite.railo:8080/$1 ProxyPassReverse /
http://testsite.railo:8080/ </IfModule> #Deny access to admin except for local/portforwarded clients
<Location /railo-context/> Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location> </VirtualHost>
This tells apache to forward all requests for CFM files to the railo instance.
Finally restart apache and railo and you should be good to go.
sudo /opt/tomcat/bin/shutdown.sh
sudo /opt/tomcat/bin/startup.sh
sudo /etc/init.d/apache2 restart