Configuring Multliple Sites On IIS 7

Posted By : todd sharp Posted At : May 12, 2007 9:37 AM Posted In: IIS

5

If you're playing along at home since my my last post you should now have the latest and greatest version of ColdFusion installed successfully on IIS.

So now what? Well now we take advantage of the fact that we can create multiple sites under one root. As a refresher here is the example I mentioned in the last post:

  • wwwroot
    • site1
      • components
        • myComponent.cfc
    • site2
      • components
        • myComponent.cfc
In the example above I might have the following code under site1:
<cfset obj = createObject("component", "site1.components.myComponent")>
Which gives us a major headache when we move site1 to production and it's now lying in the root. What would really be cool is if we could have both site1 and site2 set up as seperate sites on the server so that we could call:
<cfset obj = createObject("component","components.myComponent")>
from either site1 or site2 and have both work as expected. That's where IIS comes in. As previously mentioned I like GUIs. The GUI management console for IIS7 is pretty slick looking. Here's a screenshot of the main console:

So let's add a new site (pay no attention to test1 and test2 in that screenshot above). To add a new site right click on 'Web Sites' and select 'Add New Site'. Wow...that was tough.

This presents us with a simple dialog box of properties for our new site.

This configuration gives us a very nice and easy to use http://test1 URL on our local machine. Now that we've got a site built we can code to our hearts content assuming a simple and easy transition to our production environment. Oh - almost forgot. You'll also need to modify your hosts file to get your system to recognize the host header you specified in IIS. Here's what it should look like when you're done (assuming you followed my example above and created test1 and test2).

And that is all. As I said in my last post I am under the impression that there is no limitation to the amount of sites you can run on IIS7. This is a nice change from the previous limitations of only being able to run a single site at a time.

Related Blog Entries

Comments (5)

William from Lagos's Gravatar Cool!

Can you also do this (adding multiple sites) for IIS 5.1 on Win XP Pro?

todd sharp's Gravatar I don't think so. See comments in my last post (http://cfsilence.com/blog/client/index.cfm/2007/5/...)

Bill Staples's Gravatar Cool, great to see ColdFusion developers taking advantage of IIS7! Great post!

Emilio's Gravatar I use Vista Business with IIS7. In my system the field you show as "Host Header" appears as "Hostname".

I set it to "mysitetest" and also added the entry for mysitetest aliased to the localhost IP (127.0.0.1) and flushed the dns (ipconfig /flushdns) but when I try http://mysitetest/ on the browser rather than getting my site I get the IIS7 splash screen instead.

If I remove the "hostname" (host header in your figure) and leave it blank then I can access my site using the IP address (http://192.168.0.65/).

Sinuy's Gravatar hi when i access to http://localhost/CFIDE/administrator/index.cfm, dumps this error :
HTTP Error 404.3 - Not Found
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.