propcept.net

Informationen
Tutorials
Dynamic Select Boxes
Multi-Server Configuration
Präsentationen

  

Multi Server Configuration for CFML Development

If you are a CFML-Developer, chances are that your clients run applications with different versions of different CFML servers: maybe today you have to work on an application that uses ColdFusion MX 6.1, tomorrow a client requires BlueDragon, next week a long time customer needs a change in his ColdFusion 5.0 app and just yesterday a new client came along who wants an app written in ColdFusion MX 7.

To develop all these apps you have a number of possibilities:

  • You set up separate development machines for each app
  • You work with internal web servers on different ports (CF 5.0 does not have an internal web server)
  • You set up one machine with one web server and configure it to use all those application servers (forget those port numbers)

This tutorial will show you how to set up a single installation of Apache web server to work simultaneously with

  • ColdFusion 5.0
  • ColdFusion MX 6.1
  • ColdFusion MX 7.0
  • BlueDragon 6.2 JX

We are using Apache web server because it is free, and all of these application servers have a developers license, so you won't get into any licensing trouble.

We will set up our dev-environment in such a way that all application servers share the same document root directory. Besides that fact that you only need to configure one machine, this setup has another advantage: if you want to test a CFMX application against CF 5 or BlueDragon 6.2, you do not need to relocate your application, you just request a slightly different URL in your browser, instead. (Presuming, of course, that you have configured data sources, etc. in the corresponding server admin.

Enough said... let's begin

Step 1: Apache web server

First download the Apache web server from http://httpd.apache.org/download.cgi, install it and configure it to suit your needs. If you don't know how to install and configure the server, please refer to the Apache documentation or to any of the many Apache tutorials that you can find on the web.

Now let's make Apache answer to a couple of different host names. Open <Apache_Dir>/conf/http.conf in the text editor of your choice and move to the very end of the file. There you will find the NameVirtualHost directive along with a virtual host example. This section is the key to our setup. So let's configure a virtual host, and let's start with the CF5-host.


NameVirtualHost: *:80
 
<VirtualHost *:80>
   DocumentRoot E:/wwwroot
   ServerName cf5.yourdomain.com
   ErrorLog logs/cf5-error_log
   CustomLog logs/cf5-access_log common
</VirtualHost>

The first line enables the name based virtual hosts. The VirtualHost block defines a single host. Most important are the lines DocumentRoot and ServerName.

DocumentRoot defines the document root directory of this host. This line will be the same for all virtual hosts.
ServerName sets the name of the virtual server.

The lines ErrorLog and CustomLog are only necessary if you want to have separate logs for each host.

Now create four virtual hosts: one for CF5, one for CFMX 6.1, one for CFMX 7.0, and, one for BlueDragon 6.2. I called thos hosts cf5.yourdomain.com, cf61.yourdomain.com, cf7.yourdomain.com, and bd.yourdomain.com.

So far, the end of your httpd.conf should look somewhat like this:

NameVirtualHost: *:80
 
<VirtualHost *:80>
   DocumentRoot E:/wwwroot
   ServerName cf5.yourdomain.com
   ErrorLog logs/cf5-error_log
   CustomLog logs/cf5-access_log common
</VirtualHost>

 
<VirtualHost *:80>
   DocumentRoot E:/wwwroot
   ServerName cf61.yourdomain.com
   ErrorLog logs/cf61-error_log
   CustomLog logs/cf61-access_log common
</VirtualHost>

 
<VirtualHost *:80>
   DocumentRoot E:/wwwroot
   ServerName cf7.yourdomain.com
   ErrorLog logs/cf7-error_log
   CustomLog logs/cf7-access_log common
</VirtualHost>

 
<VirtualHost *:80>
   DocumentRoot E:/wwwroot
   ServerName bd.yourdomain.com
   ErrorLog logs/bd-error_log
   CustomLog logs/bd-access_log common
</VirtualHost>


To make those hosts work in your browser, you'll have to either register them in your name server or you simply add them to your hosts file. On Windwos XP systems this file is located in C:\Windows\system32\drivers\etc; add the following lines to your file (change the server names to your settings!):


127.0.0.1	cf5.yourdomain.com
127.0.0.1	cf61.yourdomain.com
127.0.0.1	cf7.yourdomain.com
127.0.0.1	bd.yourdomain.com

To test your virtual hosts, save the changes to httpd.conf, restart the Apache service and request an HTML file for each host. Of course, CFM files won't work yet.

If your Apache installation works so far, it is time to move on to the next step.

Step 2: ColdFusion 5.0

Download ColdFusion 5.0 from the Macromedia web site at http://www.macromedia.com/support/coldfusion/downloads.html ("ColdFusion Server 5 Developer Edition Software" at the bottom of the page) and install it.

During installation you need to make sure two things:

  1. Even if you have IIS installed, make sure that you select "Other server" as web server



  2. Make sure you have the install wizzard point to the correct document root directory



After you necessary reboot, download the ColdFusion 5 ApacheModule mod_coldfusion.so from http://home.nextron.ch/coldfusion/. The module that is designed to work for Apache 2.0.43-2.0.48 works perfectly for Apache 2.0.54! Save the downloaded file to the <Apache_Dir>/modules directory.

Now open your httpd.conf again and modify the CF5 virtual host entry to recognize the module:

<VirtualHost *:80>
   DocumentRoot E:/wwwroot
   ServerName cf5.yourdomain.com
   ErrorLog logs/cf5-error_log
   CustomLog logs/cf5-access_log common
 
   #Coldfusion 5 module
   LoadModule coldfusion_module modules/mod_coldfusion.so
   AddHandler type-coldfusion cfm dbm
</VirtualHost>

Save the file, restart Apache and test it by calling a CFM-file through your CF5 virtual host.

Step 3: ColdFusion MX 6.1

You can download ColdFusion MX 6.1 from Macromedia at http://www.macromedia.com/cfusion/tdrc/index.cfm?product=coldfusion (you will have to register to have access to this download page) and install it.

During installation, make sure you select the internal web server:

It is important to select the internal web server, because we will use that server to access the CF admin console even after we set up our virtual host for CF MX!

Before you continue, back up your httpd.conf file!

Now connect CF MX to your Apache web server by using the Web Server Configuration Tool. On Windows you'll find it in the start menu under All Programs --> Macromedia --> Macromedia ColdFusion MX. Select "Apache" as your web server and point the connector to your conf-directory.

After the connector tool has closed, open your httpd.conf file in your editor again. Search for the string jrun and you will find a block labelled #JRun Settings (usually right before the virtual host blocks). Move this block, including the whole block that begins with <IfModule mod_jrun20.c> into your CFMX 6.1 virtual host directive. That block should now look like this:

<VirtualHost *:80>
   DocumentRoot E:/wwwroot
   ServerName cf61.yourdomain.com
   ErrorLog logs/cf61-error_log
   CustomLog logs/cf61-access_log common
   
   # JRun Settings
   LoadModule jrun_module "C:/CFusionMX61/runtime/lib/wsconfig/1/mod_jrun20.so"
   <IfModule mod_jrun20.c>
      JRunConfig Verbose false
      JRunConfig Apialloc false
      JRunConfig Ssl false
      JRunConfig Ignoresuffixmap false
      JRunConfig Serverstore "C:/CFusionMX61/runtime/lib/wsconfig/1/jrunserver.store"
      JRunConfig Bootstrap 127.0.0.1:51010
      #JRunConfig Errorurl <optionally redirect to this URL on errors>
      AddHandler jrun-handler .jsp .jws
   </IfModule>
</VirtualHost>

Save the file, restart Apache and test your CF MX 6.1 virtual host.

Step 4: ColdFusion MX 7.0

IMPORTANT: Before you continue, it is recommended that you stop all ColdFusion MX services and you also should back up your httpd.conf file or the previous step may be lost!

Download ColdFusion MX 7.0 from Macromedia at http://www.macromedia.com/cfusion/tdrc/index.cfm?product=coldfusion. (You will have to register to have access to this download page.)

During the installation, again make sure you select the internal web server:

ColdFusion MX 7.0 will notice that port 8500 is already in use and switch to port 8501.

After the installation finished, launch the Web Server Configuration Tool. (On Windows: Start --> All Programs --> Macromedia --> ColdFusion MX 7 --> Web Server Configuration Tool). Select "Apache" as your web server and point the connector to your conf-directory.

Open httpd.conf again follow the same procedure as with CFMX 6.1: Search for the string JRun and move the configuration block into the corresponding virtual host directive so that it looks like this:

<VirtualHost *:80>
   DocumentRoot E:/wwwroot
   ServerName cf7.yourdomain.com
   ErrorLog logs/cf7-error_log
   CustomLog logs/cf7-access_log common

   # JRun Settings
   LoadModule jrun_module "C:/CFusionMX7/runtime/lib/wsconfig/1/mod_jrun20.so"
   <IfModule mod_jrun20.c>
      JRunConfig Verbose false
      JRunConfig Apialloc false
      JRunConfig Ssl false
      JRunConfig Ignoresuffixmap false
      JRunConfig Serverstore "C:/CFusionMX7/runtime/lib/wsconfig/1/jrunserver.store"
      JRunConfig Bootstrap 127.0.0.1:51011
      #JRunConfig Errorurl <optionally redirect to this URL on errors>
      #JRunConfig ProxyRetryInterval 600
      #JRunConfig ConnectTimeout 15
      #JRunConfig RecvTimeout 300
      #JRunConfig SendTimeout 15
      AddHandler jrun-handler .jsp .jws
   </IfModule>
</VirtualHost>


Oh... you did back up yourhttpd.conf, didn't you? Because the web server connector tool removed the CFMX 6.1 connector setting... so restore the correct block from your back up.

You did NOT back up the conf file? Don't panic... we can fix that, too:

  • copy the JRun connector block into your CF MX 6.1 virtual host
  • change the CF7 path to the correct CF6 path
  • Change the bootstrap port in the CF6 block to 51010: JRunConfig Bootstrap 127.0.0.1:51010

Save httpd.conf, restart Apache and test your new virtual host.

Step 5: Bluedragon 6.2 JX

First thing you have to do is, you guessed it, download the software from New Atlanta: http://www.newatlanta.com/c/products/bluedragon/download/home. Make sure you download the JX version and NOT the free server. The free server can only connect to Microsoft IIS. However, the JX version is available for free as a developer version, so you won't break any license agreement. (Just as with ColdFusion MX, you will have to register in order to download the software.)

During the installation of BlueDragon JX, unlike the ColdFusion MX installations, you should choose to connect to Apache web server server.

The BlueDragon admin console will always be accessible through the internal web server only, no matter which option you choose here.

After the installation, for the last time open httpd.conf. This time search for the string servlet. At first you will find a line like this:

LoadModule servletexec_module modules/Apache2ModuleServletExec.dll

Move it to your BlueDragon virtual host.

At the very end of your file you should find a section beginning with

ServletExecInstances default 127.0.0.1:9999

Move that entire block into your BlueDragon virtual host directive, which now should look similar to this:

<VirtualHost *:80>
   DocumentRoot E:/wwwroot
   ServerName bd.yourdomain.com
   ErrorLog logs/bd-error_log
   CustomLog logs/bd-access_log common
   
   LoadModule servletexec_module modules/Apache2ModuleServletExec.dll
   
   ServletExecInstances default 127.0.0.1:9999
   ServletExecAliases default /servlet servlet .jsp .cfc .cfm .cfml
   
   <Location /servlet>
      SetHandler servlet-exec
   </Location>

   <Location servlet>
      SetHandler servlet-exec
   </Location>

   AddHandler servlet-exec jsp
   AddHandler servlet-exec cfc
   AddHandler servlet-exec cfm
   AddHandler servlet-exec cfml
</VirtualHost>

Save the file, restart Apache and test your last virtual host.

That's it. You have successfully configured your Apache web server to work with four different CFML application servers. But, how can you be sure that each virtual host connects to the correct application server? Simple enough, just output a few variables in a single test template.

<cfoutput>
   Serving #cgi.script_name#<br>
   server.coldfusion.productname: #server.coldfusion.productname#<br>
   server.coldfusion.productversion: #server.coldfusion.productversion#<br>
</cfoutput>

Save the file as <DocumentRoot_Dir>/getServerVersion.cfm and request it in your browser using the different virtual hosts:

http://cf5.yourdomain.com/getServerVersion.cfm

http://cf61.yourdomain.com/getServerVersion.cfm

http://cf7.yourdomain.com/getServerVersion.cfm

http://bd.yourdomain.com/getServerVersion.cfm

 

Last, but not least: do you remember where to find your different admin consoles? Just to be sure, here's the list:

CF 5: http://cf5.yourdomain.com/CFIDE/administrator/index.cfm
CF MX 6.2: http://localhost:8500/CFIDE/administrator/index.cfm
CF MX 7.0: http://localhost:8501/CFIDE/administrator/index.cfm
BD 6.2 JX: http://localhost:8080/bluedragon/admin/index.cfm

If you want to, you can create web server mappings for the CF MX 6.1 and the CF MX 7.0 admin consoles. After adding

Alias /CFIDE/ "C:/CFusionMX61/wwwroot/CFIDE"

to the CF 6 virtual host, you can reach the CF MX 6.1 administrator though

http://cf61.yourdomain.com/CFIDE/administrator/index.cfm

Please note that a web server mapping won't work for BlueDragon; due to security reasons, it's admin console can only be contacted via the BD internal web server.

We're done. Nothing more to do, except maybe a couple of CF/BD admin settings (data sources, client variable storage, and the like). So keep those clients with all their different requirements coming... ;-)