Categories
Contact Doug!
Learn About Doug!
View Doug Boude's online resume
updated 11/18/2009

View Doug Boude's profile on LinkedIn
Link to me!

Follow Doug Boude on Twitter
Follow me!

Be Doug's friend on Facebook
Befriend me!
(I promise not to follow you home)
OO Lexicon
Chat with Doug!
Recent Entries
You may also be interested in...
Web Hosting

<< June, 2013 >>
SMTWTFS
1
2345678
9101112131415
16171819202122
23242526272829
30
Search Blog

Recent Comments
Re: Disappearing IE Popup Window During Save/Open Dialog (by LZ at 4/20 7:58 AM)
Re: Create Dynamic WHERE Clauses in PHP (by pooja at 3/20 7:29 AM)
Re: Just What IS a 'Service Layer', Anyway? (by EugenK at 3/07 7:56 PM)
Re: Using Google as your CF Mail Server (by 5starwebteam.com at 2/25 1:27 AM)
Re: Why Provide for Service layer objects in CFWheels? (by Steven Benjamin at 1/25 11:43 AM)
Re: What is an 'Advanced' Coldfusion Developer? (by ColdFusion Developer at 12/24 5:14 AM)
Re: Equivalent of SQL "TOP X" in Oracle (by Ashenafi Desalegn at 12/06 5:29 AM)
Re: PHP Export to Excel Snippet (by serene at 12/05 1:44 AM)
Re: Just What Is 'Application Logic', Anyway? (by Arif at 11/13 8:06 AM)
Re: Hosts File Changes Not Acknowledged on Vista 64 (by Aaron at 10/22 2:31 PM)
Re: PHP Export to Excel Snippet (by Jafar Shah at 10/10 4:28 AM)
Re: Viewing Option Text (in IE7) that's Wider than the Select List (by Chenelle S at 10/04 12:53 PM)
Re: PHP Export to Excel Snippet (by Kilo at 9/26 5:20 PM)
Re: Porting Coldfusion Code to Mura (by tariq at 9/03 9:51 AM)
Re: Just What IS a 'Service Layer', Anyway? (by James at 8/27 4:06 PM)
Re: Calculating Business Hours (by helen at 8/14 2:54 AM)
Re: What IS 'Business Logic', Anyway? (by dougboude at 8/06 11:30 AM)
Re: What IS 'Business Logic', Anyway? (by Adrianne at 8/06 10:29 AM)
Re: Family Law: The Weapon of Choice for Woman Scorned (by dougboude at 8/04 4:39 PM)
Re: Family Law: The Weapon of Choice for Woman Scorned (by Lola LB at 8/04 7:43 AM)
Archives
Photo Albums
Funnies (5)
Family (3)
RSS

Powered by
BlogCFM v1.11

06 September 2010
Configuring Apache To Use Multiple Versions of ColdFusion

This post is for those of you out there who have managed to get two or more versions of Coldfusion running side by side, but are now facing the challenge of HOW on earth you can actually run your apps in both versions using Apache. For example, now you'd like to test your app in CF9 by typing in "localhostCF9/myKillerApp" and in CF8 by typing in "localhostCF8/myKillerApp".  In theory, this is a no brainer, but when it comes down to answering the question of "okay...how do i configure my dev environment to allow me to do such a thing?", this is where I found myself in a fog.

Before you go on, you should know that locally I use Apache as my web server, not IIS, so this post is heavily focused on Apache only. If any of you have accomplished the topic of this post using IIS, feel free to leave a link in the comments!

PREREQUISITES TO THIS POST

This post assumes that you're already at a certain point: Apache is installed and working, and you have multiple instances/versions of CF installed and working. If you DO meet this criteria, you may want to just skip to the "Tying it All Together" section. If not, I have info and recommendations to share regarding meeting this criteria.


STARTER RECOMMENDATIONS, IF YOU NEED THEM

Although my development environment is Windows, I'm not using IIS as my local web server, but rather Apache. If you don't already have Apache installed and/or are not an admin type who enjoys digging in to config files, I highly highly recommend that you install a little product called WAMPServer (http://www.wampserver.com/en/download.php). It is an uber simple app that will install Apache, Mysql, and PHP on Windows, and then provide an easy interface for managing those products. From one tiny interface you can restart services, add/change Apache, PHP, and MySQL versions, edit config files, and add/remove PHP modules. In our case (CF lovers), PHP is ONLY relevant because that is what drives PHPMyAdmin, the app included with WAMPServer that provides a nice easy web-based interface to your MySQL installation (I use it heavily).

If you haven't already gone through the exercise of installing multiple versions of CF, and since that IS your first step in all of this, I highly recommend the lovely Daria Norris' tutorial (found here http://www.cfgothchic.com/blog/post.cfm/my-cfmeetup-presentation-installing-multiple-versions-of-coldfusion) as THE place to start. A couple of things that I did while following her instructions that you may also want to bear in mind:

1. during the install, when you get to the part about connecting to existing web servers, just tell CF to use its own internal server;
2. One thing Daria mentioned briefly that I didn't catch until I listened to her presentation a second time is that you should not specify a root context when installing your instance of CF8; just leave it blank (unless you really understand what that means and are comfortable changing it). If you don't know what a root context even is, no biggie; you'll encounter the question that uses the phrase, and you'll now know to just leave it blank.

MAKE SURE CF IS WORKING RIGHT

Okay, so let's make the assumption that at this point you have installed CF9 and have two instances running: one that is CF9 and another that is CF8. At this point you will have three different admins: one that is the 'super' admin for the master enterprise installation of CF9; one for the new instance of CF9 that you added; and one for the instance of CF8 that you added. Since we told CF that we were using the internal web server, you should be able to reach each of these now via URLs that resemble the following: http://127.0.0.1:8300/CFIDE/administrator/index.cfm, where port 8300 = the super installation, 8301 = the CF9 installation, and 8302 = the CF8 installation. Once you can hit the admins for each install using those URLs, you're ready to proceed. To verify what the correct port numbers are, you can look in the "Instance Manager" portion of the super admin interface

coldfusion 9 administrator showing the instance managerThe CF9 Instance Manager

MAKE SURE APACHE IS WORKING RIGHT
Let's also assume that you have created a URL that Apache uses to hit the local web site we will be using for testing. This post won't delve deep into the details of doing that, but I will share the following snippets.

1. line in my hosts file (C:\WINDOWS\system32\drivers\etc\hosts):

127.0.0.1       localhost

2. line block in my apache config file  :

<VirtualHost *:80>
    DocumentRoot "D:/Inetpub/wwwroot"
    ServerName localhost
</VirtualHost>

(how to edit the config file when using WAMPServer)

Now, place a simple html file at the path you specified as the DocumentRoot above. Make sure you restart your apache server after making the change (as demonstrated in the video above), and close and re-open your browser so it will see the changes to the hosts file. After that, you should be able to browse to http://localhost/[yourtestpage.html] and view it. This will tell you that Apache is working fine and the virtual host is configured correctly.


TYING IT ALL TOGETHER

SO, how do we get CF and Apache talking? The big picture answer is, by telling the JRun server to create a ColdFusion proxy for us that Apache can use to pass requests to for processing. After we get the proxy created, we will then create the Apache virtual hosts we want and instruct Apache to use the proxy for those virtual hosts, handing off requests to the appropriate CF instance.

1. Create the Proxy

The way to get this proxy created is to run the Web Server Configuration Tool. You will find it under Start/Programs/Adobe/Coldfusion 9 (multiserver version)/Web Server Configuration Tool , or you can go directly to C:\JRun4\bin\WSConfig.exe to kick it off. Just click 'Add' and tell it about your web server.

(Hint: If you DID opt to install WampServer, your Apache config file will be found at C:\wamp\bin\apache\Apache2.2.11\conf , and your Apache binary (asked about when you click on the 'Advanced' button) is at C:\wamp\bin\apache\Apache2.2.11\bin\httpd.exe. Do browse these first to verify the paths, just in case yours is a little different)


2. Verify Your Proxy Creation

After you finish, the way to verify that all went well is to take a peek in the folder C:\JRun4\lib and make sure a sub folder called "wsconfig" was created, that itself contains a subfolder (named 1, or 2 probably). If those exist, so far so good.

3. Verify Apache Proxy Configuration

The web server configuration, in addition to creating the proxy, also touched your Apache configuration file and added a few lines. Open your Apache config file (like you did earlier when you created the virtual host) and take a gander near the bottom. Those lines should look similar to this:

# JRun Settings
LoadModule jrun_module "C:/JRun4/lib/wsconfig/2/mod_jrun22.so"
<IfModule jrun_module>
    JRunConfig Verbose false
    JRunConfig Apialloc false
    JRunConfig Ignoresuffixmap false
    JRunConfig Serverstore "C:/JRun4/lib/wsconfig/2/jrunserver.store"
    JRunConfig Bootstrap 127.0.0.1:51000
</IfModule>

I want you to ignore the "loadModule...." line, BUT remove (copying and saving somewhere temporarily...very important!) all of the JRunConfig lines. After you have removed those lines, save your config file and restart Apache, just to make sure the config file is good up to this point.

(note: IF you wish to have a default version of CF to be used when NOT utilizing one of the version-specific domains/virtual hosts we will be creating, then LEAVE this section of code in place)

4. Make a Tweek to the JRUN.XML Files
Each of the ColdFusion instances that you are running can be found by looking in the  "C:\JRun4\servers" folder. You should see folders there named according to each of the instances you created before. Mine are named CF8 and CF9. Inside of each of those folders, under SERVER-INF, you will find the jrun.xml file (path to my CF8 jrun.xml: C:\JRun4\servers\CF8\SERVER-INF\jrun.xml). For each instance's jrun.xml file, we are going to open it up and make one change, and note one setting within it.


Change 1: Search for the jrun proxy section ("<service class="jrun.servlet.jrpp.JRunProxyService" name="ProxyService">"). Within that section is a setting called "deactivated"; make sure it is set to 'false' (<attribute name="deactivated">false</attribute>).

Item to Note: In that same section, note the value of the 'port' attribute. You will need to know this port number in order to tell Apache what version of CF to use for a specific virtual host. In my case, the attribute looks like this:

<attribute name="port">51000</attribute>

5. Create Your Own Virtual Hosts for Each Version

Okay, finally down to last step: creating domains/virtual hosts that will both point to the same content, yet serve it up using a different version of ColdFusion! We first need to decide on a domain name for each version. Myself, I chose to use "localCF9" and "localCF8" as my CF-specific domain names. So, step 1 in creating a new virtual host is to edit my hosts file. I added the following lines:

127.0.0.1 localCF9
127.0.0.1 localCF8

Save hosts, making sure you don't inadvertently save it as 'hosts.txt'...if using notepad, make sure you do a 'save as' and change the type to 'all files'). Now, let's edit our Apache config file again, adding two more virtual hosts blocks that resemble the following:

<VirtualHost *:80>
   ServerName localCF9
   DocumentRoot "D:/Inetpub/wwwroot"
</VirtualHost>

<VirtualHost *:80>
   ServerName localCF8
   DocumentRoot "D:/Inetpub/wwwroot"
</VirtualHost>

You'll notice that I am pointing both virtual hosts to the same folder as its root...the root of my local environment. I am doing this because I want ANYTHING I browse to via the 'localCFx' domains to be dealt with by the appropriate CF versions. Before you go on, it's a good idea to restart Apache again and just make sure you can browse to localCF9/[yourtestpage.html] and localCF8/[yourtestpage.html] just to make sure all is well with the virtual host configuration. Remember to close and reopen your browser so it 'sees' the changes to hosts file.

6. FINAL STEP
The final step is for us to inform Apache that, anytime it receives a request for a particular virtual host, it needs to hand that request off to a specific Coldfusion version via the proxy that was created for us. Go back and grab the settings you saved from the config file earlier, the ones that look like

    JRunConfig Verbose false
    JRunConfig Apialloc false
    JRunConfig Ignoresuffixmap false
    JRunConfig Serverstore "C:/JRun4/lib/wsconfig/2/jrunserver.store"
    JRunConfig Bootstrap 127.0.0.1:51000

and paste it INSIDE of each of your virtual host blocks for localCF8 and localCF9. Then, change the Boostrap port number to match what you found in the jrun.xml files for each instance. Here is my final virtual hosts blocks:

<VirtualHost *:80>
   ServerName localCF9
   DocumentRoot "D:/Inetpub/wwwroot"
    JRunConfig Verbose false
    JRunConfig Apialloc false
    JRunConfig Ignoresuffixmap false
    JRunConfig Serverstore "C:/JRun4/lib/wsconfig/2/jrunserver.store"
    JRunConfig Bootstrap 127.0.0.1:51000
    AddHandler jrun-handler .cfm .cfml .cfc .jsp
</VirtualHost>
<VirtualHost *:80>
   ServerName localCF8
   DocumentRoot "D:/Inetpub/wwwroot"
    JRunConfig Verbose false
    JRunConfig Apialloc false
    JRunConfig Ignoresuffixmap false
    JRunConfig Serverstore "C:/JRun4/lib/wsconfig/2/jrunserver.store"
    JRunConfig Bootstrap 127.0.0.1:51002
    AddHandler jrun-handler .cfm .cfml .cfc .jsp
</VirtualHost>

Notice they both use the same jrunserver store, but they each are 'talking to' the proxy via a different port. This port number is what tells JRun which instance should receive the request. Also notice that I added an "AddHandler" line to each of the blocks; without this, Apache treated my cfm files like text files. Also, if in step 2 you left a default version of CF in place, you may also have to add the "AddHandler" line to that section if CFM templates aren't served up as expected.


THE FINAL TEST

As a final test, I created a cfm page that dumped the SERVER scope AND dumped an object that I created using a simple CFC that contained only a single "init" method that returned 'this'. I recorded the demo for you to see, highlighting the cf version in each.


FURTHER READING
These sites, along with Daria Norris' tutorial on initially setting up the multiple versions, were of great help to me! And a special thank you to the awesome Mr. Stephen Moretti who managed to get me on the right track initially and who wrote one of the blog posts below.

http://www.cfgothchic.com/blog/post.cfm/my-cfmeetup-presentation-installing-multiple-versions-of-coldfusion


https://www.adobe.com/livedocs/jrun/4/JRun_Administrators_Guide/connectors2.htm


http://nil.checksite.co.uk/index.cfm/2006/5/3/cfmx-multiserver-set-up


http://www.simonwhatley.co.uk/configuring-coldfusion-8-with-apache




Posted by dougboude at 3:37 AM | PRINT THIS POST! |Link | 3 comments
Subscription Options

You are not logged in, so your subscription status for this entry is unknown. You can login or register here.

Re: Configuring Apache To Use Multiple Versions of ColdFusion
Great post Doug and a good reference for us who still have to try this out. You're great man, keep on the good work!
Posted by ComboFusion on September 6, 2010 at 5:17 AM

Re: Configuring Apache To Use Multiple Versions of ColdFusion
Good writeup! s there a similar writeup for us Macheads? Although I do have a laptop PC that I should probably get back to fiddling around with . . . soon as things die down housewise (painting) and my schedule gets more organized . . .
Posted by Lola LB on September 6, 2010 at 6:28 AM

Re: Configuring Apache To Use Multiple Versions of ColdFusion
Hi,

have you tried installing CF9 and CF10
on a single server using Apache VirtualHosts?

Thanks,

Junior
Posted by Junior Lazuardi on May 30, 2012 at 7:43 AM

Name:   Required
Email:   Required your email address will not be publicly displayed.

Want to receive notifications when new comments are added? Login/Register for an account.

Time to take the Turing Test!!!

One plus Nineteen equals
Type in the answer to the question you see above:

Your comment:

Sorry, no HTML allowed!