Installing Railo 3 on SUSE 10 with Apache2 and Tomcat: Part 2

In my previous post we set up our SUSE 10 VM, Installed Apache and Tomcat and got Tomcat to start up without throwing any error messages. In this post we will continue with the installation of Railo and then hook Tomcat up to Apache, and finally make an index.cfm page and check that everything is working.

Installing Railo

For this particular setup we will be using the Railo Custom distributon, which you can download from http://railo.ch/en/index.cfm?treeID=224. In Putty I did the following.

cd /home
mkdir data
cd /data
wget http://railo.ch/down.cfm?item=/railo/remote/download/3.0.2.001/custom/all/railo-3.0.2.001-jars.tar.gz
tar xvf railo-3.0.2.001-jars.tar.gz
mv railo-3.0.2.001-jars/* /usr/local/tomcat/lib
rm -r railo-3.0.2.001-jars
We now have all the Railo Jar files inside the Tomcat lib directory we can now set up a Tomcat servlet to handle our ColdFusion pages.

Setting Up Tomcat

If you have trouble with vi or vim then take a look at this quick reference.

vim /usr/local/tomcat/conf/web.xml
insert the following xml snippet just after the first tag you find.

<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>
Once you have done that you need to add a couple entries to the so that Tomcat will actually process the files.

<welcome-file>index.cfm</welcome-file>
<welcome-file>index.cfml</welcome-file>
Lastly we set up a default website in Tomcat's server.xml to point to our default location of /srv/www/htdocs/

<Host name="localhost" appBase="/webapps/railo">
<Context path="" docBase="/var/www/htdocs"/>
</Host>

Hooking Up Apache and Tomcat

To hook Apache and Tomcat together we need to set up a workers.properties file which specifies things like the Tomcat default port, host, connector type etc. The file contents are as follows.

worker.list=default
worker.default.port=8009
worker.default.host=localhost
worker.default.type=ajp13
worker.default.lbfactor=1
create the workers.properties file in /etc/apache2/ Once that is created you then need to tell Apache to use the workers.properties file. Edit the httpd.conf file and add the following.

# settings for Mod_jk
JkWorkersFile workers.properties
DirectoryIndex index.html index.htm index.cfm index.cfml
Don't forget to check the loadmodule.conf file to make sure that mod_jk.so is included in the list. If it isn't h At this point you need to make a decision if you are going to have the whole machine support Railo or only on a virtual host by virtual host basis. I set up the virtual machine only on the localhost but you could easily set it up to support virtual hosts too. The last bit of configuration we need to do is divert all calls to cfm pages to Railo. To do this edit the default-server.conf file and the following after the tag.

JkMount /*.cfm default

Finishing Up

Now we just need to create a simple .cfm file in /srv/www/htdocs, restart Apache and Tomcat and we are good to test our installation.

The Time Now is: <cfoutput>#now()#</cfoutput>
Start up Apache and Tomcat to make sure that they both start up without errors and then call up your brower and you should see the output, the now() replace with the current Railo time.

8 Comments to "Installing Railo 3 on SUSE 10 with Apache2 and Tomcat: Part 2"- Add Yours
Jamie Krug's Gravatar Gary, you've once again helped me in my quest to experiment with Railo, thanks! After much tinkering, I was able to use this post to help me accomplish the same type of configuration with JBoss 4.2.3 (instead of Tomcat). Now, I can't say whether I've done it the correct/recommended way, but it works! Using the Railo EAR/WAR methods with JBoss, I just couldn't find a way to get multiple virtual hosts working without using context paths. Using this post I basically just had to find the right locations for the Railo jars to go and which web.xml and server.xml files to modify in JBoss (because it's actually using Tomcat as its Web server) -- they are, respectively, {jboss}/server/{config}/lib, {jboss}/server/{config}/deploy/jboss-web.deployer/conf/web.xml and {jboss}/server/{config}/deploy/jboss-web.deployer/server.xml. In my Ubuntu setup these all ended up under /opt/jboss/server/default/ ({jboss}=/opt/jboss and {confg}=default).

I will blog the details soon, and again, not sure this is a recommended method, but it works!

Cheers,
Jamie
# Posted By Jamie Krug | 2/27/09 6:26 AM
Jamie Krug's Gravatar I also meant to mention a couple other quick points. I assume you'll need a "JkMount /*.cfc default" if you have any HTTP-accessible CFCs with remote access methods (Web Service, AJAX, etc.). Also, if you peak in the web.xml file in the railo.war, there are a couple more servlet/servlet-mapping definitions -- one is for Flash remoting.
Best,
Jamie
# Posted By Jamie Krug | 2/27/09 6:30 AM
Chris's Gravatar Gary,

Can you explain this:
<Host name="localhost" appBase="/webapps/railo">
<Context path="" docBase="/var/www/htdocs"/>
</Host>

So is /var/www/htdocs where you would store your web files? What is the appBase?

The reason I ask is that it looks like mine is pointing in the /webapps directory instead of the root of my webserver.

Thanks,
Chris
# Posted By Chris | 3/9/09 6:56 PM
Gary's Gravatar @Chris,
that may well be a mistake on my part since we haven't deployed railo as a war or an ear in this case so we don't have a railo deployment in the webapps directory.
I believe the appBase should be pointing to the root of your virtual host in this case. Either way it doesn't seem to have an effect. I even tested it by leaving out the appBase all together and it didnt seem to have an effect.
To be completely honest I am not entirely sure if we even need the appBase in this case. I will ask Gert Franz.
# Posted By Gary | 3/10/09 11:44 AM
Gary's Gravatar @Chris,

according to Gert Franz from Railo: if the appbase and the codebase are the same directory you will end up with a web-inf directory in every subdirectory of your webroot.

And after testing it I can confirm that is exactly what happens.
# Posted By Gary | 3/10/09 2:49 PM
Chris's Gravatar Thanks Gary for the response. What ended up being my problem was having a host tag embedded in another host tag. Oops! :)
# Posted By Chris | 3/10/09 4:56 PM
Chris's Gravatar My default documents (index.cfm) aren't working, ie http://localhost gives a 403 error. However, if I do http://localhost/index.cfm it works. All other cfm files work too, any ideas on this?

Apache2.2, Tomcat 6
# Posted By Chris | 4/10/09 8:05 PM
Chris's Gravatar Nevermind, adding this to the virtual host seemed to solve it.

DirectoryIndex index.cfm

Thought I did it, but it was just the default host, not the one I was trying. Glad it's Friday! :)
# Posted By Chris | 4/10/09 8:17 PM

Powered By Railo

Subscribe

Subscribe via RSS
Follow garyrgilbert on Twitter Follow me on Twitter
Or, Receive daily updates via email.

Tags

adobe air ajax apple cf community cfml coldfusion examples ext flash flex google javascript jquery max2007 max2008 misc open source programming railo software technology ui

Recent Entries

No recent entries.

Blogroll

An Architect's View
CFSilence
Rey Bango
TalkingTree

Wish List

My Amazon.com Wish List