In my last blog post, I walked through the steps of installing ColdFusion 10 on Windows with Apache as the web server. I'm going to build on that in this post and show you how you can create additional ColdFusion instances and tie them to multiple virtual hosts in Apache (the multiple virtual hosts part is often referred to as multihoming).
For the purposes of this blog post, I'm going to assume that you've already installed ColdFusion 10 in the Server Configuration (Not EAR/WAR deployment). I'm also going to assume you chose to install Apache as your web server during the install process. This gives you a single instance of ColdFusion 10 (cfusion) with Apache connected to ColdFusion as localhost.
Now let's suppose I want to do two things. I want to have two instances of ColdFusion, cfusion (the default instance) and a new instance, cfusion2. For the cfusion instance I want two virtual hosts, one for localhost and one for zeus1.foo.com. For my cfusion2 instance, I want a single virtual host for zeus2.foo.com. Here are the steps to create that configuration. I'm doing this on a Windows install, but the basic process is the same across platforms. To visualize, the setup will look like this:
cfusion (instance 1)
+--localhost
+--zeus1.foo.comcfusion2 (instance 2)
+--zeus2.foo.com
The first thing we need to do is create our new ColdFusion instance (cfusion2). To do this, we need to fire up the ColdFusion Administrator. Once logged in, click on the Instance Manager link in the Enterprise Manager section. Here you'll see a list of currently configured instances. To create a new instance, click the Add New Instance button:

Enter cfusion2 in the Server Name box. Leave the Server Directory as-is, and make sure to check the Create Windows Service box. When you're finished, click Submit.

It generally takes a few minutes for ColdFusion to create the instance. When it's finished, you'll see a screen with a link back to the Enterprise Manager. Go ahead and click the link once it appears:

Once you're back in the Instance Manager, you should see the new cfusion2 instance. Notice how the HTTP Port column shows 8500? This is because the new instance is setup to use Tomcat's built-in web server. Don't worry about that right now, we'll get to fixing that in just a minute. For now, just note the value in the Remote Port column for your cfusion2 instance as we'll be needing it shortly.

If you're wondering where ColdFusion 10 physically puts the directory structure for your instances, it's directly in the /ColdFusion10 install root:

With our two instances created, it's time to make some changes to ColdFusion's underlying Tomcat server configuration and Apache Tomcat connector configuration. We'll tackle the Tomcat configuration for the cfusion2 instance first. Fire up your favorite text editor and open the server.xml file located in:
C:\ColdFusion10\cfusion2\runtime\conf
About halfway down the file, you should see a line of XML that looks like this:
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
<Connector port="8013" protocol="AJP/1.3" redirectPort="8446" tomcatAuthentication="false">
1<Connector port="8013" protocol="AJP/1.3" redirectPort="8446" tomcatAuthentication="false">
Verify that the Connector Port matches the Remote Port you noted earlier from the Instance Manager for the cfusion instance.
At the bottom of the file, you should see some additional XML that looks like this:
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
<Connector port="8500" protocol="org.apache.coyote.http11.Http11NioProtocol" connectionTimeout="20000" redirectPort="8443" executor="tomcatThreadPool">
</Connector>
1<Connector port="8500" protocol="org.apache.coyote.http11.Http11NioProtocol" connectionTimeout="20000" redirectPort="8443" executor="tomcatThreadPool">
2</Connector>
This code is used to configure Tomcat's built-in web server. Since we want to connect our ColdFusion instance to Apache, we need to disable this. To do that, simply comment it out and save the file:
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
<!--
<Connector port="8500" protocol="org.apache.coyote.http11.Http11NioProtocol" connectionTimeout="20000" redirectPort="8443" executor="tomcatThreadPool">
</Connector>
-->
1<!--
2<Connector port="8500" protocol="org.apache.coyote.http11.Http11NioProtocol" connectionTimeout="20000" redirectPort="8443" executor="tomcatThreadPool">
3</Connector>
4-->
Now that we've disabled the built-in web server, we need to tell Tomcat we want to use Apache as our web server instead. To do this, we have to make some changes to the Apache Tomcat connector ColdFusion previously installed. The connector and its associated configuration files can be found here:
C:\ColdFusion10\config\wsconfig\1
The connector itself is compiled and named mod_jk.so. There's not much to do with it other than to verify that it's there. The two files that we're interested in for our instance configuration are workers.properties and uriworkermap.properties.
The workers.properties file is used to configure your server instances. If you open it up in a text editor, you'll see that it's configured for your default cfusion instance:
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
worker.list=cfusion
worker.cfusion.type=ajp13
worker.cfusion.host=localhost
worker.cfusion.port=8012
1worker.list=cfusion
2
3worker.cfusion.type=ajp13
4worker.cfusion.host=localhost
5worker.cfusion.port=8012
To add our additional cfusion2 instance, we simply have to make two changes:
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
worker.list=cfusion, cfusion2
worker.cfusion.type=ajp13
worker.cfusion.host=localhost
worker.cfusion.port=8012
worker.cfusion2.type=ajp13
worker.cfusion2.host=localhost
worker.cfusion2.port=8013
1worker.list=cfusion, cfusion2
2
3worker.cfusion.type=ajp13
4worker.cfusion.host=localhost
5worker.cfusion.port=8012
6
7worker.cfusion2.type=ajp13
8worker.cfusion2.host=localhost
9worker.cfusion2.port=8013
worker.list should contain a comma delimited list of all of the server instances you have. Below that, you need to configure the properties for each instance. You only need to concern yourself with the port here. Each ColdFusion instance gets its own port, which you can obtain from the Instance Manager in the ColdFusion Administrator.
Next, make a copy of your uriworkermap.properties file and name it uriworkermap_cfusion2.properties. The ColdFusion 10 docs tell you to rename it to uriworkermap1.properties, but I don't like that convention - especially if you have a lot of instances. Anyhow, change all of the mappings in the uriworkermap_cfusion2.properties file so that they apply to the cfusion2 instance. Here's how that should look:
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
/cfformgateway/* = cfusion2
/CFFormGateway/* = cfusion2
/flex2gateway/* = cfusion2
/flex2gateway = cfusion2
/cffileservlet/* = cfusion2
/CFFileServlet/* = cfusion2
/cfform-internal/* = cfusion2
/flashservices/gateway/* = cfusion2
/flex-internal/* = cfusion2
/rest/* = cfusion2
/*.cfml/* = cfusion2
/*.mxml = cfusion2
/*.as = cfusion2
/*.cfm = cfusion2
/*.cfm/* = cfusion2
/*.swc = cfusion2
/*.cfml = cfusion2
/*.cfc = cfusion2
/*.cfc/* = cfusion2
/*.cfr = cfusion2
/*.cfswf = cfusion2
/*.sws = cfusion2
/*.jsp = cfusion2
/*.hbmxml = cfusion2
1/cfformgateway/* = cfusion2
2/CFFormGateway/* = cfusion2
3/flex2gateway/* = cfusion2
4/flex2gateway = cfusion2
5/cffileservlet/* = cfusion2
6/CFFileServlet/* = cfusion2
7/cfform-internal/* = cfusion2
8/flashservices/gateway/* = cfusion2
9/flex-internal/* = cfusion2
10/rest/* = cfusion2
11/*.cfml/* = cfusion2
12/*.mxml = cfusion2
13/*.as = cfusion2
14/*.cfm = cfusion2
15/*.cfm/* = cfusion2
16/*.swc = cfusion2
17/*.cfml = cfusion2
18/*.cfc = cfusion2
19/*.cfc/* = cfusion2
20/*.cfr = cfusion2
21/*.cfswf = cfusion2
22/*.sws = cfusion2
23/*.jsp = cfusion2
24/*.hbmxml = cfusion2
That's it for the Apache Tomcat connector configuration. All that's left to do now is to setup our Apache virtual hosts, restart all of our servers and verify everything's working as expected.
Open your Apache http.conf file and notice that ColdFusion has placed the following directive at the bottom of the file:
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
# Load mod_jk module
Include "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\mod_jk.conf"
1# Load mod_jk module
2Include "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\mod_jk.conf"
Personally, I don't like the absolute path, so I usually make mine relative. I also like it in a subdirectory for virtual hosts. You don't have to move yours, it's just a personal preference of mine:
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
# Load mod_jk module
Include conf/vhosts/mod_jk.conf
1# Load mod_jk module
2Include conf/vhosts/mod_jk.conf
This directive tells Apache to load the mod_jk.conf configuration file that ColdFusion created when you told it to configure Apache as your web server.
Open your mod_jk.conf file and create the virtual hosts. Here's my mod_jk.conf file (I added some space and moved some things around to make it easier to read):
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
# Load mod_jk module
LoadModule jk_module "C:\ColdFusion10\config\wsconfig\1\mod_jk.so"
# Where to find workers.properties
JkWorkersFile "C:\ColdFusion10\config\wsconfig\1\workers.properties"
# Where to put jk logs
JkLogFile "C:\ColdFusion10\config\wsconfig\1\mod_jk.log"
# Where to put jk shared memory
JkShmFile "C:\ColdFusion10\config\wsconfig\1\jk_shm"
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
AddHandler jakarta-servlet .cfm .cfml .cfc .cfr .cfswf
<Files ~ ".hbmxml$">
Order allow,deny
Deny from all
</Files>
<VirtualHost *:80>
ServerName localhost
DocumentRoot C:/_web/cf10/cfusion/localhost/wwwroot
ErrorLog c:/_web/logs/cfusion-localhost.log
JkMountFile "C:\ColdFusion10\config\wsconfig\1\uriworkermap.properties"
<Directory "C:/_web/cf10/cfusion/localhost/wwwroot">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Alias /CFIDE "C:\ColdFusion10\cfusion\wwwroot\CFIDE"
<Directory "C:\ColdFusion10\cfusion\wwwroot\CFIDE">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName zeus1.foo.com
DocumentRoot C:/_web/cf10/cfusion/zeus1/wwwroot
ErrorLog c:/_web/logs/cfusion-zeus1.log
JkMountFile "C:\ColdFusion10\config\wsconfig\1\uriworkermap.properties"
<Directory "C:/_web/cf10/cfusion/zeus1/wwwroot">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Alias /CFIDE "C:\ColdFusion10\cfusion\wwwroot\CFIDE"
<Directory "C:\ColdFusion10\cfusion\wwwroot\CFIDE">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName zeus2.foo.com
DocumentRoot C:/_web/cf10/cfusion2/zeus2/wwwroot
ErrorLog c:/_web/logs/cfusion2-zeus2.log
JkMountFile "C:\ColdFusion10\config\wsconfig\1\uriworkermap_cfusion2.properties"
<Directory "C:/_web/cf10/cfusion2/zeus2/wwwroot">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Alias /CFIDE "C:\ColdFusion10\cfusion2\wwwroot\CFIDE"
<Directory "C:\ColdFusion10\cfusion2\wwwroot\CFIDE">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
1# Load mod_jk module
2LoadModule jk_module "C:\ColdFusion10\config\wsconfig\1\mod_jk.so"
3# Where to find workers.properties
4JkWorkersFile "C:\ColdFusion10\config\wsconfig\1\workers.properties"
5# Where to put jk logs
6JkLogFile "C:\ColdFusion10\config\wsconfig\1\mod_jk.log"
7# Where to put jk shared memory
8JkShmFile "C:\ColdFusion10\config\wsconfig\1\jk_shm"
9# Set the jk log level [debug/error/info]
10JkLogLevel info
11# Select the timestamp log format
12JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
13
14AddHandler jakarta-servlet .cfm .cfml .cfc .cfr .cfswf
15
16<Files ~ ".hbmxml$">
17Order allow,deny
18Deny from all
19</Files>
20
21 <VirtualHost *:80>
22 ServerName localhost
23 DocumentRoot C:/_web/cf10/cfusion/localhost/wwwroot
24 ErrorLog c:/_web/logs/cfusion-localhost.log
25
26 JkMountFile "C:\ColdFusion10\config\wsconfig\1\uriworkermap.properties"
27
28 <Directory "C:/_web/cf10/cfusion/localhost/wwwroot">
29 Options Indexes FollowSymLinks
30 AllowOverride None
31 Order allow,deny
32 Allow from all
33 </Directory>
34
35 Alias /CFIDE "C:\ColdFusion10\cfusion\wwwroot\CFIDE"
36
37 <Directory "C:\ColdFusion10\cfusion\wwwroot\CFIDE">
38 Options Indexes FollowSymLinks
39 AllowOverride None
40 Order allow,deny
41 Allow from all
42 </Directory>
43</VirtualHost>
44
45 <VirtualHost *:80>
46 ServerName zeus1.foo.com
47 DocumentRoot C:/_web/cf10/cfusion/zeus1/wwwroot
48 ErrorLog c:/_web/logs/cfusion-zeus1.log
49
50 JkMountFile "C:\ColdFusion10\config\wsconfig\1\uriworkermap.properties"
51
52 <Directory "C:/_web/cf10/cfusion/zeus1/wwwroot">
53 Options Indexes FollowSymLinks
54 AllowOverride None
55 Order allow,deny
56 Allow from all
57 </Directory>
58
59 Alias /CFIDE "C:\ColdFusion10\cfusion\wwwroot\CFIDE"
60
61 <Directory "C:\ColdFusion10\cfusion\wwwroot\CFIDE">
62 Options Indexes FollowSymLinks
63 AllowOverride None
64 Order allow,deny
65 Allow from all
66 </Directory>
67</VirtualHost>
68
69 <VirtualHost *:80>
70 ServerName zeus2.foo.com
71 DocumentRoot C:/_web/cf10/cfusion2/zeus2/wwwroot
72 ErrorLog c:/_web/logs/cfusion2-zeus2.log
73
74 JkMountFile "C:\ColdFusion10\config\wsconfig\1\uriworkermap_cfusion2.properties"
75
76 <Directory "C:/_web/cf10/cfusion2/zeus2/wwwroot">
77 Options Indexes FollowSymLinks
78 AllowOverride None
79 Order allow,deny
80 Allow from all
81 </Directory>
82
83 Alias /CFIDE "C:\ColdFusion10\cfusion2\wwwroot\CFIDE"
84
85 <Directory "C:\ColdFusion10\cfusion2\wwwroot\CFIDE">
86 Options Indexes FollowSymLinks
87 AllowOverride None
88 Order allow,deny
89 Allow from all
90 </Directory>
91</VirtualHost>
Note that for my cfusion instance where I want to have two virtual hosts, one for localhost and one for zeus1.foo.com, I've added the same jkmountfile directive to each virtual host like so:
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
JkMountFile "C:\ColdFusion10\config\wsconfig\1\uriworkermap.properties"
1JkMountFile "C:\ColdFusion10\config\wsconfig\1\uriworkermap.properties"
All virtual hosts on a single instance should point to the same uriworkermap.properties file since that file specifies the mapping at the instance level.
For my cfusion2 instance, the single virtual host points to uriworkermap_cfusion2.properties:
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
JkMountFile "C:\ColdFusion10\config\wsconfig\1\uriworkermap_cfusion2.properties"
1JkMountFile "C:\ColdFusion10\config\wsconfig\1\uriworkermap_cfusion2.properties"
That's it for configuration. Go ahead and stop and start both of your ColdFusion instances and your Apache web server just to make sure all changes are reflected.
Test out the URLs for each of your virtual hosts to make sure everything is pointing where it should be:
http://localhost
http://zeus1.foo.com
http://zeus2.foo.com
Now open the ColdFusion administrator on localhost:
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
http://localhost/CFIDE/administrator
1http://localhost/CFIDE/administrator
Everything should load up fine. In the Mappings section of the Administrator, /CFIDE and /gateway point to the correct locations:
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
C:/ColdFusion10/cfusion/wwwroot/CFIDE
C:/ColdFusion10/cfusion/gateway/cfc
1C:/ColdFusion10/cfusion/wwwroot/CFIDE
2C:/ColdFusion10/cfusion/gateway/cfc
Repeat the same process for your other virtual hosts, making sure the /CFIDE and /gateway mappings point to the correct locations for your instances.
That's it, you should now be configured for multiple instances of ColdFusion with multiple Apache virtual hosts.
2/24/12 1:35 AM
Hi Rob,
Thanks for the great post! Only thing I would add to this would be to make sure each of your JVM's run under a different user. Otherwise, if you need to shut things down because one of your instances is doing things like keeping more than one 'Java' instance in memory, then you'll have to run a killall java, which will shut all of those workers down.
The easiest way to prevent this is to simply put your JVM instances under different User paths, so that say when you want to startup/shutdown cfusion2, then you do something like sudo -u cfusion2 startup etc. Then, only that instance gets restarted correctly if you have to kil all java for some reason.
Not sure if that's different with CF10, but I have 4 Tomcats running on my server utilizing multi-instances of Railo.
Anyway, thanks again!
All the best,
David
5/30/12 7:41 AM
Hi,
do you have instructions for installing CF9 and CF10
in a single server using Apache VirtualHosts?
Thanks,
Junior
6/4/12 3:03 PM
Rob,
Thanks for your detailed walk-through. My coworkers and I have tried following the steps many times but still aren't able to get CF10 working properly with multihoming. We've been able to create multiple instances and get the virtual directories set up in Apache web server but the ColdFusion Administrator always goes to the cfusion instance. We've tried various changes to the mod_jk.conf file (as well as other files) but still aren't able to get things isolated properly. Are you able to access the individual ColdFusion Administrator instances (and do they properly show up as cfusion, cfusion2, etc.)?
6/5/12 4:03 PM
It looks like we're having a problem with the virtual directories. I was able to set up the cfusion virtual host as well as an additional host without any problem. I was then able to access each instance of the ColdFusion 10 server. However, when I try to add another virtual host using the same steps, Apache refuses to restart. If I remove the other additional virtual host, Apache restarts without problems. Hmm...
6/6/12 10:27 AM
David,
Hit me up on Twitter or the email address on my contact page and I'll see if we can't get to the bottom of your issue.
6/8/12 11:24 AM
Rob,
Your offer to help seems to have resolved my problems! I decided to give it one more go (and reboot three times) and of course everything finally started working. Go figure.
Thanks again for the detailed write-up!
David
9/12/12 7:46 PM
I assume this is for Enterprise version only and can't be done with Standard?
10/29/12 1:42 PM
Hey Rob: brilliant! Thanks for the easy-to-follow and well-explained article. I followed it through and it worked first time.
A coupla questions / observations:
* I like having the inbuilt webserver running in case I need to have a fallback in case the "main" web server starts giving me hassles, or I just want to factor it out if there's weirdness going on. So I left that stuff enabled. It did not cause any problems.
* I have my virtual hosts set up in the Apache-default location of httpd-vhosts.conf. So I moved that stuff from mod_jk.conf into that file, and it worked perfectly. The one downside is that this means the mod_jk config stuff is split across two files as the uriworkermap.properties ref needs to be in the vhosts file, but I see this as a better trade-off compared to having a bunch of vhosts stuff in the "wrong" file (it's not "wrong", but you see what I mean, hopefully).
Now I just gotta coerce my Railo instance to hook into Apache too, and I'm away laughing. Hopefully it'll be a variation on these instructions.
Mate: I owe you a beer or three. Hopefully we'll cross paths at a conference before too long (it'll need to be SotR as it's the only one I can afford). Thanks dude.
--
Adam
12/24/12 3:47 PM
Any advice on how to get CF 10 working with this setup, only serving .html files that contain CFML?
So far I have tried:
1. Adding /*.html = cfusion and /*.htm = cfusion to my uriworkermap_cfusion.properties file.
2. Adding .htm and .html to the AddHandler jakarta-servlet .cfm .cfml .cfc .cfr .cfswf line in my apache conf file.
.cfm files and CF Admin render correctly, but when I call a .html file that contains CFML I get a Tomcat error saying the requested resource is not available.