Well that headline is a bit of a mouthful, but i figured if this was something I was attempting to do then there was a good chance that others were attempting the same thing – and what I really could have done with is a guide. So here’s that guide.
First of all I started with a default install of Ubuntu Server 8.04, the latest LTS release. There’s no reason why this shouldn’t work on 8.10 though.
First things first, install Java.
sudo apt-get install sun-java6-jdk
That should all without a hitch and the next step is to get Tomcat installed. The version available through is apt is version 5.5 and I wanted to use the latest release so after logging in to the server download the latest (6.0.18 at this time) by executing
wget http://apache.hoxt.com/tomcat/tomcat-6/v6.0.18/bin/apache-tomcat-6.0.18.tar.gz tar xvzf apache-tomcat-6.0.18.tar.gz
Next we need to move Tomcat somewhere permanent.
sudo mv apache-tomcat-6.0.18 /usr/local/tomcat
The next thing to do is set Tomcat to automatically start when the server starts (plus the script makes it easier to start and stop Tomcat). Start up your editor of choice.
sudo nano /etc/init.d/tomcat
And paste in the following script (which I got originally from HowToGeek.com)
# Tomcat auto-start # # description: Auto-starts tomcat # processname: tomcat # pidfile: /var/run/tomcat.pid export JAVA_HOME=/usr/lib/jvm/java-6-sun case $1 in start) sh /usr/local/tomcat/bin/startup.sh ;; stop) sh /usr/local/tomcat/bin/shutdown.sh ;; restart) sh /usr/local/tomcat/bin/shutdown.sh sh /usr/local/tomcat/bin/startup.sh ;; esac exit 0
The script also need to be made executable and hooked up to the startup folders.
sudo chmod 755 /etc/init.d/tomcat sudo nano /etc/init.d/tomcat sudo ln -s /etc/init.d/tomcat /etc/rc1.d/K99tomcat sudo ln -s /etc/init.d/tomcat /etc/rc2.d/S99tomcat
Tomcat should now be up and running!
To install Railo we first need to get the Railo custom version and copy all of the files into the Tomcat lib directory.
wget http://www.railo-technologies.com/railo/remote/download/3.0.1.000/custom/all/railo-3.0.1.000-jars.tar.gztar zxvf railo-3.0.1.000-jars.tar.gzsudo mv railo-3.0.1.000-jars/* /usr/local/tomcat/lib
The next step is to get Railo and Tomcat working together. I’ve assumed that you’re only using Tomcat for CFML processing so these instructions only cover installing Railo on a server wide basis rather than being site specific.
Open up the web config file
sudo nano /usr/local/tomcat/conf/web.xml
and append 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>
Inside the <welcome-file-list> element insert the following
<welcome-file>index.cfm</welcome-file> <welcome-file>index.cfml</welcome-file>
This tells Tomcat what files to process and what to do with them.
Next we need Apache. Originally I had installed this by selecting the LAMP stack while installing Ubuntu but if you missed that step then go for
sudo apt-get install apache2
There are various ways to connect Apache and Tomcat, but we’ll be using mod_jk which you can install on Ubuntu by typing in
sudo apt-get install libapache2-mod-jk
To specify the connection between Apache and Tomcat we set up a file called workers.properties and list the different connectors. Create the file in the Apache directory
sudo nano /etc/apache2/workers.properties
and paste in the following
worker.list=default worker.default.port=8009 worker.default.host=localhost worker.default.type=ajp13 worker.default.lbfactor=1
We then tell apache where this file is by adding the following to your /etc/apache2/httpd.conf
# Mod_jk settings JkWorkersFile workers.properties DirectoryIndex index.html index.htm index.cfm index.cfml
To use Railo on a website we need to configure it in both Apache and Tomcat. In Tomcat’s server.xml (/usr/local/tomcat/conf/server.xml if you’re following my instructions) add the following (you can add many of these if you need to set it up for each application)
<Host name="your.url.com" appBase="/var/www/vhosts/yoursite"> <Context path="" docBase=""/> </Host>
Finally we add the following to your site’s apache vhost config (most likely in /etc/apache2/sites-available)
JkMount /*.cfm default
This tells mod_jk to use the default connector (as specified in the workers.properties file) whenever it encounters a file ending in .cfm. By setting it up this way we can still use apache to server static files like images, css and js (or even run another language like php side by side with ColdFusion)
Last thing to do is to drop some Coldfusion into your website and check that everything is working.