Multiple ColdFusion Sites on IIS Without Apache!

Occasionally, I stumble across claims about what a pain it is to setup multiple ColdFusion sites for a local development environment under IIS or even worse, that it just can't be done. This is flat out false. It's actually quite simple to get set up, and I'll show you two (2) different methods to do this.

The first option is to simply use a unique port with your localhost. So that for example if you navigate to http://127.0.0.1:81, you can view your site. You could then have another site under port 82 and so on. I've even included a short video tutorial to show you how to do this below:

Option 1

As you can see, it's quite easy! However, if you're developing more than a few web sites, it can be difficult to remember which site is on what port. So let's take a look at my preferred method.

Our second option is to modify your "hosts" file and then add a header in IIS for your site. Your header can be anything you like. However, I usually use the domain name along with ".loc" or ".local" to keep things unique. So, when I view the site in my browser, the URL would look like "www.mydomain.loc" or something like that. To see how to set this up, view the video tutorial below:

Option 2

And that's it! I certainly hope this has helped someone get going on IIS with ColdFusion.

Peace.

Comments

I think the issue was that IIS6 limited local installs to one active site. From what I understand the restriction was removed in IIS7.

And I prefer method 2 (hosts file mod) -- I usually use the domain name without the TLD -- so my local blog is http://cfsilence/blog.

PS - what did you use to create those screencasts. They look pretty good.
# Posted By todd sharp | 7/23/09 1:18 PM
@todd,

I remember having an issue with IIS on XP in general ... if I remember correctly, you had to have XP Pro to really do anything with it.

However, I really wanted to point out that you _can_ (and have been able to for quite some time now) setup and use IIS quite easily and reliably.

Thanks, and the screencasts were created with Jing: http://www.jingproject.com/
# Posted By Steve Withington | 7/23/09 3:11 PM
Thanks for this article.

I would like to advise you of my method, which could be considered a 3rd method, and I use it both in my personal 127 space and the real www on current 24 sites using a single IP / computer.

This works when u are in a shared hosting enviroment, and cant access IIS.

In the host file I have add:

127.0.0.1 vvvvvv.mydomain.co.za --- those are 'v''s not 'w' 6 of them.

This is useful for doing demo's and screen shots to simulate live sites, at home in my dev 127 enviroment.

Now the magic part is a bit of xml and cfm code, and has been on my live www site for over 3 years without fail.

I dont fiddle with the host file but rather with the dns records for my live services, and I plan them in a way I could use both.

<cfparam name="domain" default="mydomain.co.za">
<cfset domain = replace(cgi.SERVER_NAME, 'www.', '')>

<cffile action="read" variable="url_wddx" file="C:\www\mydomain\_\domain_listing.xml">
<cfwddx action="wddx2cfml" input="#url_wddx#" output="qry_wddx">

<cfquery dbtype="query" name="qry" maxrows="1">
SELECT *
FROM qry_wddx
WHERE COL_URL ='#domain#';
</cfquery>

<cfif qry.recordcount EQ 1>
<cflocation url="http://#qry.col_sub#.#qry.col_http#/#qry.col_dir#/...; addtoken="no">
<cfelse>
<cflocation url="http://127.0.0.1/"; addtoken="no">
</cfif>

Now u will need to use a simulated db (wddx packet), as the service provider's sql source may not always be online, I assume it is never online.

<?xml version="1.0" encoding="iso-8859-1"?>
<wddxPacket version="0.9">
<header />
<data>
<recordset rowCount="24" fieldNames="url,sub,http,dir">

<field name="col_url">
<string>domain.co.za</string>
...
<string>mydomains.co.za</string>
</field>

<field name="col_sub">
<string>www</string>
...
<string>www</string>
</field>

<field name="col_http">
<string>domain.co.za</string>
...
<string>mydomains.co.za</string>
</field>

<field name="col_dir">
<string>one</string>
....
<string>many</string>
</field>

</recordset>
</data>
</wddxPacket>

I hope this give you a better idea
# Posted By Jets | 7/24/09 10:57 AM
@Jets,

Very interesting approach. Thanks for sharing!
# Posted By Steve Withington | 7/24/09 1:04 PM

© 2024, Stephen J. Withington, Jr.  |  Hosted by Hostek.com

Creative Commons License   |   This work is licensed under a Creative Commons Attribution 3.0 Unported License.