Connect Apache HTTPD To Railo On Windows

Author: Steven Neiland
Published:

Warning: This blog entry was written two or more years ago. Therefore, it may contain broken links, out-dated or misleading content, or information that is just plain wrong. Please read on with caution.

With the recent release of Railo4 I have decided to switch from ColdFusion to Railo as my primary development cfml engine. This comes at a good time for me as I just built myself a new development machine so I am starting with a clean environment.

Now I have installed Railo on linux multiple times without any issue, and likewise on windows machines running IIS. However my new development machine runs on windows but uses Apache httpd instead of IIS. This is a problem as it seems the windows installer does not have an option for installing the apache connector. So here is how you install the connector manually.

PreRequisites

This guide assumes you have already installed apache httpd and railo using their installers.

Step 1: Get the connector

The first step is obviously to get the The Apache Tomcat Connector from the tomcat website. Note that there are different connectors for different versions of Apache. I run apache 2.2 so I downloaded tomcat-connectors-1.2.37-windows-i386-httpd-2.2.x.zip file from the Windows Binaries section.

Step 2: Extract And Install The Module File

Extract the downloaded zip file and then copy mod_jk{version number}.so to "{apache install dir}/modules/mod_jk.so"

Step 3: Load The Module

With the module file saved open the httpd.conf file and add the follow code block to the LoadModules section.

<IfModule !mod_jk.c>
LoadModule jk_module modules/mod_jk.so
</IfModule>

Step 4: Configure "jk_module" To Handle ".cf*" Files

With the httpd.conf file still open, go to the bottom of the file and copy in this code block to configure apache to pass cfml files to tomcat for processing.

<IfModule jk_module>
JkMount /*.cfm ajp13
JkMount /*.cfc ajp13
JkMount /*.do ajp13
JkMount /*.jsp ajp13
JkMount /*.cfchart ajp13
JkMount /*.cfres ajp13
JkMount /*.cfm/* ajp13
JkMount /*.cfml/* ajp13
JkMountCopy all
JkLogFile logs/mod_jk.log
JkShmFile logs/mod_jk.shm
</IfModule>

Step 5: Configure Apache To Serve index.cfm by Default

One final step. Still in the httpd.conf file, locate the DirectoryIndex command and add index.cfm to the list of files to server as a directory index.

<IfModule dir_module>
DirectoryIndex index.cfm index.html
</IfModule>

Save these changes and restart the httpd service. You should now be up and running.

Note To Self: Confirm Directory Access

This is not really related to this problem but I'm putting it in as a note for myself.

I created a "test.localhost" domain with the folder being located in my user workspace. When I accessed the site with http://test.localhost/ i got a 403, yet when I went to http://test.localhost/index.cfm it worked. The problem was I had not allowed indexes for my workspace folder where I normally put my projects.

<Directory "C:/Users/Steven/workspace">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

Reader Comments

Yves H's Gravatar
Yves H
Wednesday, January 2, 2013 at 6:21:04 PM Coordinated Universal Time

Hi!

Thank you very much for this great article! I'm currently running an ACF 8 server with apache 2.2 on Windows and I'd like to switch over to Railo 4. That's why I followed your tutorial and installed Railo with Tomcat 7 and the mod_jk for Apache. But if I now try to access a cfm file on a virtual host which already exists, I get a 404 error, because Railo doesn't look for the cfm file in Apache's documentroot, but in the webapps directory from Tomcat.

Do I have to create a webapp in tomcat for every virtualhost I have in Apache? I really hope not, since I have a lot virtual hosts. :-/

Thanks and best regards
Yves

Steven Neiland's Gravatar
Steven Neiland
Wednesday, January 2, 2013 at 6:30:51 PM Coordinated Universal Time

Yves,
Yes you need to create a host entry for each vhost in the tomcat server.xml file.

However I believe there is a vhost copier that automates the process for you. I have not used it myself but here is a link to the article about how to use it.

http://www.railodeveloper.com/post.cfm/apache-iis-to-tomcat-vhost-copier-for-railo

Yves's Gravatar
Yves
Thursday, January 3, 2013 at 4:16:13 AM Coordinated Universal Time

Thank you Steven, I'll try this Railo extension.

Jeff Gladnick's Gravatar
Jeff Gladnick
Tuesday, June 18, 2013 at 2:07:08 PM Coordinated Universal Time

So this works EXCEPT railo is trying to load my local virtual host here:
C:\railo\tomcat\webapps\ROOT\

instead of in my local /inetpub/wwwroot/mywebapp

I can't figure out why. Where is this defined. I have the correct directory in server.xml and httpd.conf.

Steven Neiland's Gravatar
Steven Neiland
Tuesday, June 18, 2013 at 2:11:28 PM Coordinated Universal Time

Jeff,
Send me an email with your httpd.conf and httpd-vhosts files plus server.xml file and I will have a look OR send me a pastebin link.

Jeff's Gravatar
Jeff
Tuesday, June 18, 2013 at 2:42:47 PM Coordinated Universal Time

Sent! (to your gmail)

Nick Karasek's Gravatar
Nick Karasek
Thursday, August 15, 2013 at 8:44:52 PM Coordinated Universal Time

Hi Jeff - thanks (of course) for the info detailed above. Small/bigish problem when accessing railo via a directory, however (not a full domain). After modifications, The cfm files get served from the Railo ROOT/MyDirectory properly but references to files (resources, images, css, ...) get served from the WAMP directory wamp/www/MyDirectory/ (resources, images, css, ...).
Simply setting a <directory> in apache's httpd.conf is helping. Any suggestions? Note that I have NOT done anything to server.xml - not sure how to use <directory> in there - if it is needed at all. Thanks for any help you can give. N

Nick Karasek's Gravatar
Nick Karasek
Thursday, August 15, 2013 at 8:46:47 PM Coordinated Universal Time

My apologies Steven - I addressed my previous comment to "Jeff" who was simply asking a question of you. Nick

  • Please keep comments on-topic.
  • Please do not post unrelated questions or large chunks of code.
  • Please do not engage in flaming/abusive behaviour.
  • Comments that contain advertisments or appear to be created for the purpose of link building, will not be published.

Archives Blog Listing