Thursday, 25 October 2012

Railo via IIS

This is just some feedback from a comment someone made on this blog at some point to the effect that "getting Railo to work with IIS was a nightmare" (paraphrase).  I can't actually find the comment now, so you'll just have to take my word for it. I do know that someone else I was talking to today or yesterday also said much the same thing.  And there was a thread on the Railo Google Group in which someone was bleating about this or similar too (I just glossed over it, as admin stuff bores me rigid). I was concerned there was some substance to this, so decided to check for myself.

Here's what I did:

  1. Downloaded the latest Railo with Tomcat installer from the Viviotech website. I used this one instead of the one on because I wanted to test something the Viviotech bods had fixed in this version of the installer that I was commenting about on the Railo Group. It's the same version of Railo as on, just a newer installer.  At time of writing this is Railo And the installer I was using was the BETA 3 one.
  2. Ran the installer, using pretty much the default options.  I installed Railo to C:\apps\railo.
  3. Went into IIS Manager and set up a new website "railotomcat", homed in D:\webapps\railo\www (note that that is a different drive entirely from where Railo was installed), using a host header of "railotomcat.local"
  4. Added "railotomcat.local" to my hosts file, pointing to
  5. Googled how to connnect IIS to Railo, and after a few minutes and some visits to irrelevant or obsolete pages, landed on a page on the getRailo site that detailed the IIS connector, over on the Boncode RIAForge page.
  6. I downloaded and ran that, following my nose (because that is about as informed as my opinion gets on the various things it asked; it was always reassuring that the defaults would be fine, so I believed it).  I opted to only set the connector up for the IIS website I mentioned above (as opposed to "all of them" which was the other option).
  7. I did some more googling to find out how to move the location of Railo's root from the install I did before to be homed in the IIS website I created above.  I found an excellent article by Sean which showed me how to do it. It was a matter of opening up C:\apps\railo\tomcat\conf\server.xml and adding this:

<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" resolveHosts="false"/>
    <Valve className="mod_cfml.core" loggingEnabled="false" waitForContext="3" />

    <Context path="" docBase="D:/webapps/railo"/><!-- THIS DID NOT WORK. DO NOT COPY THIS -->
(The grey bit was already there, I just included it for context.  I just added the black bit)

Note the docBase is the parent directory of the web-browseable IIS website root which was D:\webapps\railo\www. I did this because I wanted Railo to be able to serve files from above the webroot as well as the web-browseable ones.  As per my highlight, this did not work: Railo was looking for D:\webapps\railo\www\helloWorld.cfm in D:\webapps\railo\helloWorld.cfm.  Which is, of course, entirely reasonable on Railo's part given the info I had given it.  I'm sure I could have configured this exactly the way I wanted with a bit more help from Google, but I decided "yeah, I'm over googling and installing stuff now", so I took a shortcut to effect the results I wanted (see below).  So I changed that <context> entry to point to the www directory instead.
  1. I restarted Tomcat.
  2. Err...
  3. ... that's it.
That worked fine.

So I guess I am either lucky, or... there... isn't a problem here?  Or maybe Railo's moved-on since people were having problems?  Anyway, it was piss easy, there was nothing at all that had me scratching my head.  I think the whole process took me about 2h, but within that I had to mess around with IIS as work out how 7.5 did some stuff these days... I haven't used IIS regularly since v6, so the newer interface is not so familiar to me, and I had to google a bit; I was also doing other things at the same time, plus there was a bit of cross-referencing different docs I found which covered re-homing Railo which didn't quite seem to match, until I found Sean's page.  Oh, but I did the Railo install itself last night, so that's not part of that 2h.  I reckon if I started again now, it'd be about 20min work, including download and installation time.  Not a hardship.

So that's good!

Oh.  I solved the issue of getting Railo to know about stuff in the parent directory to its root directory by just remapping "/" in my Application.cfc.  I'm actually moderately surprised this worked.  But it did.

// Application.cfc
component {        = "railotomcat";
    this.mappings    = {
        "/" = expandPath("../")

Heh... after all that: I don't actually use IIS as a rule: I use either the built-in web server (mostly) or Apache if I want to get all flash and "production-grade" about things.  So I'll have a look at connecting Apache tomorrow (or let's just say "another day", at this point).  I did have a slight question mark about the Apache stuff because I've already got CF10 configured to serve CFML stuff from my Apache install, and I don't know how to say "only use CF10 from the virtual hosts I specify (and ditto Railo for other virtual hosts)".  Obviously (?) it's possible but I dunno how to do it yet.

It's slightly more horsing around doing this with Railo than it is with ColdFusion, but not so much I am annoyed about it (I hate doing "sysadmin stuff" if I can avoid it, so I get annoyed quickly).  All good.

Cheers Railo!