ModCFML

Apache on Windows

The following steps cover all the steps necessary for install the mod_cfml.pm module into Apache on a Windows System. The steps are intended to be thorough, so you may not need to take each step on your own system. For example, you may already have Apache and some of the required modules installed on your system. Feel free to skip those steps as needed.

IMPORTANT: At this point mod_cfml has only been tested on 32-bit Windows/Apache installations.

Installing Apache

installing Apache on a Windows is as simple as downloading the "msi" installer from the Apache website. At the time of this writing, the download URL is here:

-> http://httpd.apache.org/download.cgi

We recommend the "Win32 Binary including OpenSSL" version.

Selecting the defaults and installing a "Typical" install should be just fine for most situations. The following will assume you're installing Apache 2.2 with the defaults.

Configuring mod_proxy

Mod_proxy is a connector, that is, it passes requests off to Tomcat for processing, thus "connecting" Apache to Tomcat. Both mod_proxy and mod_jk have been tested with mod_cfml and both work great. If you already have mod_proxy or mod_jk installed, then you may skip this step. However, since you do need one or the other installed, we will cover installing mod_proxy quickly here. This is not intended to be documentation on mod_proxy, but enough to get you up and running. Full mod_proxy documentation is avaialble on the Apache Web Site.

mod_proxy and mod_proxy_ajp are part of the default installation for the Windows "MSI" installer, however, they are disabled by default. So, we will need to edit the Apache configuration to enable mod_proxy.

In this documentation, we're going to be using "notepad" to edit our config files. In order for our user to have permission to edit the files we need to edit, we will need to open up "notepad" as an administrator. In Windows7 and Windows Server, you can open programs as the Administrator user by right-cliking on them and selecting "Run as Administrator", like in this Windows7 screenshot (you may be prompted to enter the administrator password):

run as administrator

Now that we have Notepad open as an Administrator, we go to File->Open, and navigate to the following:

C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf

IMPORTANT: We will use this method of opening programs as the administrator user repeatedly during this tutorial.

You may need to select the "All Files" option from the drop-down menu in order to see the httpd.conf file that you need to select.

Show All Files

The first thing that we need to do is enable mod_proxy and mod_proxy_ajp. When the file is open in Notepad, hit CTRL+F to open up the find window. In the find window, type in "proxy":

Search for Proxy

Hit the "Find Next" button, and you should be taken to the very line that we need to uncomment. See the hash tags ("#") that are in front of the proxy lines? Those need to be removed in order to uncomment them. You need to uncomment mod_proxy and mod_proxy_ajp. Like so:

Uncomment mod_proxy

Now that mod_proxy and mod_proxy_ajp have been uncommented, add the following to the very bottom of the file:

<Proxy *>
Allow from 127.0.0.1
</Proxy>
ProxyPreserveHost On
ProxyPassMatch ^/(.+\.cf[cm])(/.*)?$ ajp://localhost:8009/$1$2


The config above is designed to send any request that Apache gets that has a ".cfm" or ".cfc" in it to be passed off to Tomcat. This configuration is obviously intended for CFML processing engines like Railo or OpenBD, but you can also use a statement similar to the above to pass ".jsp" files off to Tomcat, and mod_cfml will create contexts for those sites as well. Feel free to experiment here however you need to.

Now restart Apache so your changes take effect. If you installed the Apache task-manager applet, there should be a little pink feather in your task-bar. left-click it (not right-click) hover over "Apache 2.2", and select "Restart". Right-clicking will enable you to bring up the Apache monitor window, where you can also restart Apache if you want. You will be prompted for admin rights if you're doing this as a non-administrator user.

Installing mod_perl

The mod_cfml.pm module requires mod_perl, so we need to install and enable that module in Apache. To install mod_perl on Windows, you can either download and compile the mod_perl source as discussed here, or you can take a shortcut and install ActivatePerl and have it download and compile mod_perl for you.

-> http://www.activestate.com/activeperl/downloads

IMPORTANT: It is very important that you download the MSI installer for Perl version 5.12. mod_perl only exists in this version at the time of this writing.

By default, perl will be installed to C:\perl. This is fine for our purposes. The other default options are fine as well, but you are welcome to leave out the installation of the documentation and examples if you would like a shorter install time and smaller install footprint.

Now, we need to download and compile mod_perl. You can do that by opening up an "Administrator" command window like follows:

Start -> All Programs -> Accessories -> Right-click "Command Prompt" and select "Open As Administrator"

This will give you a command-like window that has administrative rights. Next, move to c:\perl\bin, and run the following commands:

ppm rep add http://cpan.uwinnipeg.ca/PPMPackages/12xx
ppm install mod_perl

The "ppm" program will prompt you where you want the mod_perl.so file placed. If you installed Apache to the default location, the path you want to give it will be this one:

C:\Program Files\Apache Software Foundation\Apache2.2\modules


Next you will need to add the Apache "LoadModule" lines to your Apache config. Open an "Administrator Notepad" like you've done in the past, and add the following lines:

LoadFile "C:/Perl/bin/perl512.dll" 
LoadModule perl_module modules/mod_perl.so


I put the lines above right next to the mod_proxy lines we edited earlier. My file looks like this now:

mod_perl_config

Lastly, restart Apache so that your new mod_perl config goes into effect. You can restart Apache the same way you did above!

Installing mod_cfml

Now, after all the preperation, we can finally install our mod_cfml module. If you haven't already, go download the mod_cfml.pm.zip file, unzip it, and place it in the modules directory:

C:\Program Files\Apache Software Foundation\Apache2.2\modules

IMPORTANT! The link above points to version 1.0.0 of mod_cfml. Mod_cfml may have been upgraded since this documentation was written, so you may need to use an updated URL.

Now we add our mod_cfml configs to Apache. As before, open the httpd.conf file using an "Administrator Notepad:"

C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf


... and add the following config to the very bottom of the file:

PerlRequire "C:\Program Files\Apache Software Foundation\Apache2.2\modules\mod_cfml.pm"
PerlHeaderParserHandler mod_cfml
PerlSetVar LogHeaders false
PerlSetVar LogHandlers false
PerlSetVar CFMLHandlers ".cfm .cfc .cfml"


Again, note that this is configured for CFML requests. You can edit the "Handlers" value for the kinds of files that you're sending to Tomcat. (JSP or whatever). By default, mod_cfml will also update the headers on requests for default documents (any request ending in a slash: "/" ), so you don't need to worry about adding that as a handler.

Restart Apache one last time and you should be set with the mod_cfml.pm module.

What's Next?

Now that you have the mod_cfml.pm installed, you'll need to install the Tomcat Valve. The Tomcat Valve will take the information that the mod_cfml.pm file is sending it, and create the hosts automatically using that data.