Installing Railo/Tomcat on 64 bit Windows Server 2008 R2 with IIS 7.5 and Plesk – The Correct Way

November 2015 UPDATE: Obviously this is an old post but it still gets hits. Everyone should know that Railo is a dead project. The main developer has forked it into Lucee (found on lucee.org). Lucee is currently stable at v4.5x with public beta testing of v5. Lucee is by far the best non Adobe CF interpreter and I highly recommend it.

This is an update of the post on setting up my new server and my struggle to get Railo installed. After a few tips from Google Groups for Railo and specifically Mark Drew (CEO Railo UK & original author of cfeclipse, my favourite CFML editor) & Jordan Michaels (Community Deployments Coordinator – ie: the install guy), I decided to reprovision (ie: reinstall) my virtual server and give it another try. I actually did this final setup twice, once to get it to work and once to document it. I’m getting pretty good at it now 🙂

Basically, the problems I experienced in the first few times around were due to 2 things; Plesk and my confusion (or IIS 7.5 lack of clarity) as to what Enable 32 Bit Applications means. Plesk does quite a few funky things to IIS since it is a web based management tool. Much of my grief stemmed from the fact that Plesk is a 32 bit App and my server install is 64 bit. Plesk also uses but doesn’t expose a version of Tomcat. My confusion in the original post as to why the Railo Tomcat was installing itself on a different port than normal was likely due to the Plesk instance. Now we don’t want to break Plesk (I’m paying for it every month!) so we need a procedure to make it play nice and undo some of the problems it causes with IIS. The following outlines the steps needed to get Plesk, Railo, Tomcat & iis 7.5 all running happily.

The first section of my previous post outlines how to set up the server and a single website using Plesk on a GoDaddy VPS (virtual private server). I’m assuming Plesk operates pretty much the same on all II 7.5 setups so it should be pretty standard. That setup walkthrough is still valid however, as I found out, the remaining part of the post dealing with Railo & IIS is incorrect (well, not exactly incorrect – it did get things working, just not in the best way) and superseded by this. I’ve also changed the order in which I did some things so let’s get started.

Fixing what Plesk Hath Wrought

Once we’ve created our website via the Plesk panel we need to go and make some changes in IIS so fire up inetmgr

Select Application Pools under the main node of your site. You’ll notice there a couple of the standard and a couple added by Plesk.

Click Set Application Pool Defaults from the right column. Here we see that Plesk has set Enable 32 Bit Applications to True. We need to set this to false.

This was a big stumbling block for me on the first couple tries as I did not have a clear understanding as to what Enable means. For IIS 7.5 Enable means Only Allow.  So If you have this set in defaults it will create all new AppPools with 32 bit enabled preventing 64 bit apps from running. You will get an error: HTTP Error 500.0 – Internal Server Error Calling LoadLibraryEx on ISAPI filter “C:\railo\connector\isapi_redirect-1.2.31.dll” failed.

The other very confusing thing is that this seems to override individually set AppPool settings and break all 64 bit websites if 32 bit is enabled in Application Pool Defaults.  In order to have a mixed 32/64 bit environment you MUST have Application Pool Enabled 32 bit Application set to FALSE. To allow an individual site to run 32 bit apps, you need to click on the appPool you want to change and click Advanced Settings from the right column.Change the drop down from False (the default) to True

For Plesk to work we need to set  both plesk(default)(2.0)(pool) and PleskControlPanel to use 32 bit applications. Once you have done this, browse to your Plesk panel and verify everything is working.

Now that we’ve got Plesk in a 64 bit environment, we need to add an AppPool for our new website. Click Add Application Pool in the right column and give your pool a meaningful  name. The name of the website works well. Leave the other settings as they are.

Now that we’ve got that set up, we need to associate the new AppPool with the new website. Select the website in the left column and then click Advanced Settings from the right. You’ll note that the website is set up by Plesk to use plesk(default)(2.0)(pool). Click on this and then  click on the […] Select your new AppPool and click OK.

Install Railo

Not much to say here. Run the setup routine, making note of your Tomcat admin password. The installer may request that you choose a port for Tomcat. If you don’t get asked, it means that Tomcat can use the default port. If you do, it means that something is using that port. I assume it’s Plesk’s version of Tomcat? This happened twice and the rest of the time it didn’t on the various installs I’ve tried. Does Plesk choose different ports at setup? I don’t know. Remember, my install is based on an OS image with Plesk pre-installed so I don’t have any control over it’s install.

Once the install is complete and you get the first run page, set your Server & Web Admin Passwords for Railo.

Now we need to fix one more issue introduced by Plesk. This one was another stumbling block in my initial tries. Because I installed Railo immediately, I did not know that Plesk had already set up a jakarta virtual directory pointing to its own version (32 bit) isapi connector for use by its own version of Tomcat. Without going into too much detail about that, the jakarta vDir in any application that uses railo needs to be pointed at the railo isapi 64bit  connector (on a 64 bit OS). Click on the jakarta subdirectory of your website, Click Advanced Settings in the left column and  point the physical path of the Railo connector

Now we’ve cleared up all the issues caused by Plesk and it’s time to move on to the final set up of IIS 7.5

The Home Stretch

The Railo install does a lot of the work for you but we do have to do a few things. The server root node will have a Handler Mapping for *.cfm files set up, but it doesn’t seem to set it up for individual sites. Click on your website node and then Handler Mappings. Click Add Script Map from the right column. Set the Request Path to *.cf*. All the Railo walkthroughs I’ve seen only seem to add one for *.cfm. The installer only adds *.cfm but I’m not sure if it will process CFC’s if only *.cfm is set up. I assume it will but it won’t hurt to use *.cf* to cover both right?

edit: While I don’t think it will do any harm to set it to *.cf*, setting/leaving the Handler Mapping as *.cfm is fine. Now that I have an actual operating system, I was able to verify that CFCs were processed correctly with only a mapping for *.cfm

Point the executable to the {installPath}\connector\isapi_redirect-xx.xx.xx.dll and give it a name.

*note: some of the more eagle eyed of you may notice that the path in the handler mapping screen cap above shows I’m adding the Handler Mapping in the {website} > jakarta section. This was not intentional. You should be in the root node of your website when you add an handler mapping. In this case it should have been railoinstalltest.ca


Now double check that there is an entry for the isapi connector in the Isapi Filters section. This should be added by the installer but if not you can add it easily.

One final thing to do is to make sure that index.cfm is at the top of the Default Documents list (not necessary but I’d do it in any case). Index.cfm should be added by the installer, but if not you can add it.

Adding a Tomcat Webcontext

Click on Start Menu >All Programs  > Railo >Tomcat Host Config to open up the Tomcat Server.xml file (a nice touch added by the installer). Scroll to the bottom of this file to add your “webcontext”; basically tell Tomcat what directory to watch under what website. There is a template to use which is commented out with <!– –>

<!–
<Host name=”[ENTER DOMAIN NAME]” appBase=”webapps”>
<Context path=”” docBase=”[ENTER SYSTEM PATH]” />
</Host>
–>

Copy that twice and modify it to add the Hostnames of your site and the path to the document root.

<Host name=”railoinstalltest.ca” appBase=”webapps”>
<Context path=”” docBase=”C:\inetpub\vhosts\railoinstalltest.ca\httpdocs” />
</Host>

Note that there are two instances for a single site; one for http://www.railoinstalltest.ca and one for railoinstalltest.ca. You would need to repeat this for each binding your site has that you want to process cfm files. You wouldn’t need to add one for http://ftp.railoinstalltest.ca but you probably would for admin.railoinstalltest.ca

edit: Thanks to Spills in the comments for pointing me to the use of Alias. Add an alias for each binding of your site that you want to process cfm files. Saves a few lines and if you have a lot of sites, it keeps the file cleaner.

<Host name=”www.railoinstalltest.ca” appBase=”webapps”>
<Context path=”” docBase=”C:\inetpub\vhosts\railoinstalltes.ca\httpdocs” />
<Alias>railoinstalltest.ca</Alias>
</Host>

Save the file and restart Tomcat using Start Menu >All Programs  > Railo > Railo-Tomcat Service Control

Now at this point we -should- be able to browse our first cfm file. (but I bet you’re guessing maybe, just maybe we can’t?)

Create a simple one
<cfoutput> <h1>Hello World!</h1><br> The time is #now()#</cfoutput>

and save it to the httpdocs folder of your website and browse to the site and…

You’ll note the error detail Cannot read configuration file due to insufficient permissions. Now we know that the website configuration file is web.config and it is located in the document root of each website. So the error message tells us that for some reason, IIS doesn’t have permission to read that file, or more accurately, the website’s AppPool doesn’t. In IIS 7.5 the appPool is an isolated security context for each website, provided you set them up that way as we did. We need to give the appPool permissions to access the directory. Open Explorer and browse to your webroot, in this case inetpub\vhosts and select your website. Right click and select the security tab. Click Edit and then Add. In the Object Names box enter IIS AppPool\{nameof yourAppPool} or in this case IIS AppPool\railotest. Click ok.

Now at this point (again) you’d think we’d be done, but I discovered that granting permissions at the topmost level of the site doesn’t propagate the changes to lower directories like you’d expect. I’m not sure if this is a Server 2008R2 thing or something related to IIS AppPool objects but we need to do one more thing. From the Security Tab of the properties box, click Advanced > Change Permissions. Click in the Permission Entries box and select all of the entries, including the AppPool entry you just added. This step is important and failure to do so can mess up the permissions for the site. Click the Replace All Child Object Permissions With Inheritable Permissions From this Object check box. This will set the permissions of all of the subdirectories of the root website based on the permissions of the root directory (ie: the one we just added the AppPool permission). It does this for each Permission Entry in the list. As such all of the subdirectories will have permissions Read & Execute, List Folder Contents and Read set for your website AppPool.

Finally, back to the browser and …..

Ahhh, I love it when a plan (and 2 weeks, 5 OS reinstalls and several hundred cups of coffee) come together.

Unlike my previous post, I’m pretty confident that this is the correct way to get these various pieces of code to live on my webserver in glorious harmony. I didn’t realize when I started this project that I would be spending this much time just getting the server set up, but in retrospect, I’m glad it did. I have a much better understanding of how all the various pieces work and feel much better about the way my server is set up. My initial attempts led to so much random clicking of settings that I could have easily compromised the security of the server. I’m very glad that I have a VPS so flattening the server and starting again was a simple, 2-3 hours automated process which required none of my time.

As before, If you’ve got any corrections or suggestions, let me know about them in the comments.

Advertisements

4 Responses to Installing Railo/Tomcat on 64 bit Windows Server 2008 R2 with IIS 7.5 and Plesk – The Correct Way

  1. Pingback: Installing Railo, Tomcat & IIS 7.5 on MS Server 2008 r2 64bit (with Plesk thrown in to make it interesting) « Sid’s FishNet

  2. spills says:

    First off, one heck of detailed post, this should help quite a few people. I just wanted to point out a very minor thing, you don’t have to create two separate entries in Tomcat instead use
    <!–

    [DOMAIN NAME]

    –>

    spills

  3. spills says:

    Ok, problem with previous post as it didn’t like code example. I was trying to say you can use Alias instead of creating two entries in Tomcat.

    [DOMAIN_NAME.COM]

  4. JayB says:

    Thanks for that. I’ve updated the post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: