rss
twitter
    Twitter feed not available

Multiple ColdFusion 9 Instances with JRun and Apache

I was asked recently to assist with setting up multiple ColdFusion 9 instances when using Apache as the web server. When using IIS, its pretty easy to run the 'Web Site Configuration' and tell IIS which CF instance to use for which sites, but with Apache, there is a bit more involved...not a whole lot, in my opinion, but there is more. 

Note: This assumes you already have ColdFusion installed and hooked up to Apache.

First, let's create a new ColdFusion Instance. This is easy enough using the CF Administrator. (Yes, I know there are other ways, like deploying CF as a .war file but using CF Administrator is more user friendly). We create a new CF instance by navigating to the 'Enterprise Manager --> Instance Manager' in CF Administrator (you will only see this menu option in Developer and Enterprise editions of ColdFusion).

On the next page, we want to click 'Add New Instance'.



Simply fill out the form, giving the new server a 'name' (you should be able to leave the default Server Directory) and clicking 'Submit'

Now..we wait...this may take a while - once the new instance is created, it should be started automatically and you should be able to hit the CF Administrator for the new instance by going to http://localhost:{port #}/CFIDE/administrator/ where {port #} is the 'HTTP port' shown in the 'Available Servers' list.

NOTE: If, like me, you use ColdFusion debugging, and have specified a debugging port in jvm.config and have other servers running that are using jvm.config at startup, the new instance will not start - to fix this, start the new instance with a different jvm.config file or shutdown any other instances of ColdFusion that are running)

Here is where we need to take a little detour to get the information needed for Apache. If its not already started, fire up the JRun Administrator and browse to http://localhost:8000. You should be prompted for a login (the username should be 'admin' and the password will be the password you specified for CF Administrator when you first installed ColdFusion).

Once you are logged in to JRun admin, you should see a list of available servers (and your new server should be there).

If your new server is not started, start it. Once it has been started, click on the name of your new server. From here click the 'Services' menu item

On the services page, note the 'Proxy Port' specified. Also, if it is not started (which it likely is not), start the 'ProxyService' by clicking the 'play' button.

We can now close the JRun Admin (and stop the service is you so desire) and open up our Apache file used for specifying virtual hosts (depending on the version of Apache, this may be a separate file form main config).

Create a new <virtualHost> block or use an existing one and inside the <virtualHost> block add the following line:

view plain print about
1JRunConfig Bootstrap 127.0.0.1:{proxy port}


Where {proxy port} is equal to the proxy port we noted in JRun admin for our new instance.

To test that we are using the new instance, lets create a test file in the document root of our virtual host with the following code

view plain print about
1<cfdump var="#server#" />

When we view the page, we can verify the new instance is being used by looking at the 'rooter' key of the 'coldfusion' structure. In my case, it looks like this:

'Scott_test' was the name I gave my CF Instance (by default ColdFusion will create new instances in a directory under 'servers' with the same name as the instance).

I know this may seem complicated, but after you do it a few times, its pretty easy.

7 comments

(Comment Moderation is enabled. Your comment will not appear until approved.)
William said...
Can you please show it is done for IIS?
Scott Stroz said...
@William - I will try and put together a similar post for using IIS.
Debbie said...
Is Enterprise manager only available in the Enterprise edition of Coldfusion9. I am running the developer edition on my local machine, and I don't see Enterprise Manager within Coldfusion Administrator.
Scott Stroz said...
@Debbie - It is available in Developer Edition, but only if ColdFusion has been installed as 'multi-server', you will not se Enterprise Manager if you installed ColdFusion as 'Stand-alone'.
Ryan Arneson said...
Huge thank you! Just got this running.
Scott Smith said...
This post made it so easy. I have setup virtualhosts recently, but not using separate instances. Thanks!
RobG said...
Beautiful! Worked perfectly... for one instance at least. I created a second instance, and can't get the other site to come up on it (500 error). I turned off that new instance and put it back on cfusion and it's fine for now though.

BTW the IIS version is so freakin' simple it hardly needs a blog post. Just do like he said early in this article and run the connector program to specify which instance maps to which site.