Justin Carter's madfellas.com

Running CF7 and CF8 simultaneously on IIS7

Recently I started work at a new job in London and found myself needing to do some local development with CFMX7 while still keeping my existing CF8 installation available for local development as well. One option — which is what I did initially to get up and running quickly — was to run CFMX7 in stand-alone mode using the built-in web server, but eventually I needed to be able to switch between multiple projects (web roots) easily because I could be working on more than one project at a time.

Since we use IIS in our production environments it makes sense to use it in a development environment as well, rather than playing with Apache or another web server, and I also wanted to keep everything under a single web server instance so that I didn't have to worry about fiddling with port numbers and and multiple web server services. Thankfully IIS7 makes per-web site configuration really easy with it's web.config files, as you will see below.

Installation

I started with an existing CF8 installation that was originally set up to apply to all IIS web sites. I also store all my data on D: and so the the CFIDE and CFDOCS folders for CF8 were initially installed to D:inetpubwwwroot.

When it came time to install CF7 I chose to install it in server mode using the built-in web server. This places the CFIDE and CFDOCS folders for CF7 in C:CFusionMX7wwwroot, so you won't have to worry about overwriting the CF8 files.

ColdFusion Configuration

To allow IIS to talk to ColdFusion we need to make sure the JRunProxyService isn't deactivated which you can do by editing C:CFusionMX7untimeserverscoldfusionSERVER-INFjrun.xml. To do this just follow the first step in the Adobe TechNote titled ColdFusion MX: Manually configuring the web server connector for ColdFusion MX Standalone. This simply changes the deactivated value from true to false. (You can also use this opportunity to deactivate the JRun built-in web server by editing the same flag just above in the WebServer service config).

Next we need to make sure the web connector DLL's and configuration files are available. These files won't have been installed and/or created when we chose to use the built-in web server so we will have to extract and configure them manually. We could follow the rest of the above TechNote to get up and running, but it has been summarised much better (and specifically for IIS7) on page 6 of a Community MX article called Getting ColdFusion MX 7.0.2 Running on Vista and IIS. Following steps 1 to 7 you will extract the IIS related DLL files from C:CFusionMX7untimelibwsconfig.jar and create two configuration files to go with them. Give the ColdFusion MX 7 Application Server service a restart now for good measure.

IIS7 Configuration

In IIS Manager create a new web site as you would normally, with a new web root and using host headers to differentiate between web sites (e.g. create the site in D:inetpubcfmx7, give it the host header cfmx7.local and edit your hosts file to alias 127.0.0.1 as cfmx7.local).

The new site will be created with the Handler Mappings from the top level web server configuration which will be pointing to the CF8 files (meaning if you were creating a new site using CF8 then it would be ready to go without any configuration). To get this site to work with CF7 we just need to change each of the ColdFusion-related mappings to use the web connector that we just extracted and configured above.

 
IIS7 Handler Mappings for ColdFusion MX 7


Select the newly created site in the site tree, double-click on the Handler Mappings icon, and set the executable for each CF-related mapping to C:CFusionMX7untimelibwsconfig1jrun_iis6_wildcard.dll. The most important ones will be the wildcard (*), *.cfm(l), *.cfc and *.cfr, though it only takes a few seconds to configure the other 4 or 5 while you're at it.

That should be it, you will now have an IIS7 site running CFMX7! Create a new .cfm file and use <cfdump var="#server#"> to confirm :)

Creating additional CF7 sites

The beauty of IIS7 is that site-specific configuration is written to an XML file in your web root called web.config. This means no more stuffing around with the IIS metabase as in IIS6, and the benefit we get here is that you can keep a copy of this file (like a "template") and then next time you create a new web site that will use CF7, simple copy and paste the file into the web root and you are ready to rock without any additional configuration! This is what my own web.config file looks like:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <remove name="AboMapperCustom-75808" />
            <remove name="AboMapperCustom-75807" />
            <remove name="AboMapperCustom-75806" />
            <remove name="AboMapperCustom-75805" />
            <remove name="AboMapperCustom-75804" />
            <remove name="AboMapperCustom-75803" />
            <remove name="AboMapperCustom-75802" />
            <remove name="AboMapperCustom-75801" />
            <remove name="AboMapperCustom-75800" />
            <add name="AboMapperCustom-75800" path="*" verb="*" modules="IsapiModule" scriptProcessor="C:CFusionMX7untimelibwsconfig1jrun_iis6_wildcard.dll" resourceType="Unspecified" requireAccess="None" responseBufferLimit="0" />
            <add name="AboMapperCustom-75801" path="*.jsp" verb="*" modules="IsapiModule" scriptProcessor="C:CFusionMX7untimelibwsconfig1jrun_iis6_wildcard.dll" resourceType="Unspecified" requireAccess="Script" responseBufferLimit="0" />
            <add name="AboMapperCustom-75802" path="*.jws" verb="*" modules="IsapiModule" scriptProcessor="C:CFusionMX7untimelibwsconfig1jrun_iis6_wildcard.dll" resourceType="Unspecified" requireAccess="Script" responseBufferLimit="0" />
            <add name="AboMapperCustom-75803" path="*.cfm" verb="*" modules="IsapiModule" scriptProcessor="C:CFusionMX7untimelibwsconfig1jrun_iis6_wildcard.dll" resourceType="Unspecified" requireAccess="Script" responseBufferLimit="0" />
            <add name="AboMapperCustom-75804" path="*.cfml" verb="*" modules="IsapiModule" scriptProcessor="C:CFusionMX7untimelibwsconfig1jrun_iis6_wildcard.dll" resourceType="Unspecified" requireAccess="Script" responseBufferLimit="0" />
            <add name="AboMapperCustom-75805" path="*.cfc" verb="*" modules="IsapiModule" scriptProcessor="C:CFusionMX7untimelibwsconfig1jrun_iis6_wildcard.dll" resourceType="Unspecified" requireAccess="Script" responseBufferLimit="0" />
            <add name="AboMapperCustom-75806" path="*.cfr" verb="*" modules="IsapiModule" scriptProcessor="C:CFusionMX7untimelibwsconfig1jrun_iis6_wildcard.dll" resourceType="Unspecified" requireAccess="Script" responseBufferLimit="0" />
            <add name="AboMapperCustom-75807" path="*.cfswf" verb="*" modules="IsapiModule" scriptProcessor="C:CFusionMX7untimelibwsconfig1jrun_iis6_wildcard.dll" resourceType="Unspecified" requireAccess="Script" responseBufferLimit="0" />
            <add name="AboMapperCustom-75808" path="*.mxml" verb="*" modules="IsapiModule" scriptProcessor="C:CFusionMX7untimelibwsconfig1jrun_iis6_wildcard.dll" resourceType="Unspecified" requireAccess="Script" responseBufferLimit="0" />
        </handlers>
    </system.webServer>
</configuration>


Though I haven't tested it, you could probably use a similar procedure for older releases of CF such as CFMX 6.1, or maybe even future versions such as CF9 ;)

Happy configuring!