Monday, April 16, 2012

Co-existence of ColdFusion9 and ColdFusion10 using Apache web server

With ColdFusion10 Beta already out, many of us will be wondering if there is any way ColdFusion9 and ColdFusion10 can co-exist by using any of the Web Servers available. The answer is yes, it is definitely possible.  The next question which will arise is "how can it be achieved?". Well.. It can be achieved very easily by performing the steps listed below:
  1.  Firstly, Apache needs to be installed. It can be downloaded from the link http://httpd.apache.org/
  2. After Installing Apache, a virtual host setup needs to be done. For creating Virtual Hosts in Apache, refer to my previous blog entry on "Creating Virtual Hosts in Apache" or directly click on the link  http://kmaiya.blogspot.in/2011/10/creating-virtual-hosts-in-apache.html
  3. For the co-existence, we can have 2 virtual hosts set up each running on port 81 and 82. 
  4. Configure ColdFusion9 connector to Apache by launching the wsconfig UI which is located in C:\ColdFusion9\runtime\bin directory. 
  5. After configuring the connector, open the Apache's httpd.conf file which is located in the conf directory. Search for the below text in the file:
     # JRun Settings
     LoadModule jrun_module "C:/ColdFusion9/runtime/lib/wsconfig/1/mod_jrun22.so"
     
     JRunConfig Verbose false
     JRunConfig Apialloc false
     JRunConfig Ignoresuffixmap false
     JRunConfig Serverstore "C:/ColdFusion9/runtime/lib/wsconfig/1/jrunserver.store"
     JRunConfig Bootstrap 127.0.0.1:51011
     #JRunConfig Errorurl url 
     #JRunConfig ProxyRetryInterval 600 
     #JRunConfig ConnectTimeout 15 
     #JRunConfig RecvTimeout 300 
     #JRunConfig SendTimeout 15 
     AddHandler jrun-handler .jsp .jws .cfm .cfml .cfc .cfr .cfswf
        
    5.  Cut and paste the above section of code inside one of the virtual host block(host running on port 81) defined in httpd.conf. The final Virtual host block :
<VirtualHost *:81>
DocumentRoot "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs1"
ServerAdmin www.example1.com
 # JRun Settings
LoadModule jrun_module "C:/ColdFusion9/runtime/lib/wsconfig/1/mod_jrun22.so"
<IfModule mod_jrun22.c>
    JRunConfig Verbose false
    JRunConfig Apialloc false
    JRunConfig Ignoresuffixmap false
    JRunConfig Serverstore "C:/ColdFusion9/runtime/lib/wsconfig/1/jrunserver.store"
    JRunConfig Bootstrap 127.0.0.1:51011
    #JRunConfig Errorurl url <optionally redirect to this URL on errors>
    #JRunConfig ProxyRetryInterval 600 <number of seconds to wait before trying to reconnect to unreachable clustered server>
    #JRunConfig ConnectTimeout 15 <number of seconds to wait on a socket connect to a jrun server>
    #JRunConfig RecvTimeout 300 <number of seconds to wait on a socket receive to a jrun server>
    #JRunConfig SendTimeout 15 <number of seconds to wait on a socket send to a jrun server>
    AddHandler jrun-handler .jsp .jws .cfm .cfml .cfc .cfr .cfswf
</IfModule>
</VirtualHost>

       6.  Restart Apache.
       7. Configure ColdFusion10 connector to Apache by launching the wsconfig UI which is located in  C:\ColdFusion10\cfusion\runtime\bin directory. Open the httpd.conf file located in the conf directory of Apache and go to the end of the file. Copy the following line "JkMountFile "C:\ColdFusion10\config\wsconfig\2\uriworkermap.properties"" and paste it in the Virtual host block(virtual host running on port 82).
       8. Open mod_jk.conf file present in the conf directory of Apache and cut the below lines:

JkMountFile "C:\ColdFusion10\config\wsconfig\2\uriworkermap.properties"
    # Select the timestamp log format
    JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
    AddHandler jakarta-servlet .cfm .cfml .cfc .cfr .cfswf
    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>

       9. Paste it inside the other virtual host block(virtual host running on port 82) defined in httpd.conf file. The final Virtual host block:

   <VirtualHost *:82>
   DocumentRoot "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs2"
   ServerAdmin www.example2.com

   # Other directives here

   JkMountFile "C:\ColdFusion10\config\wsconfig\2\uriworkermap.properties"
   # Select the timestamp log format
   JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
   AddHandler jakarta-servlet .cfm .cfml .cfc .cfr .cfswf
   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>

       10. Restart Apache.
       11. Launch the ColdFusion9 administrator using:
              http://<server_name>:81/CFIDE/administartor/index.cfm
             Launch the ColdFusion10 administartor using:
              http://<server_name>:82/CFIDE/administartor/index.cfm
             where, <server_name> : localhost/IP address/uniquely defined server name.

Thus, by performing the above mentioned steps, CF9 and CF10 can co-exist together. This is very helpful as it saves the time required for multiple configuring/un-configuring ColdFusion connector to Apache. Any application which needs to be run on ColdFusion9 and ColdFusion10 simultaneously can be done easily.
           

7 comments:

  1. Hi, thanks this is really useful. I tried this method on Windows (success) and CentOS 5.x (failed).
    Seems that there is Apache connector problem on CentOS 5.x (even on single CF10 installation), have you managed to configured it correctly there?

    Thanks

    ReplyDelete
  2. Hi Paulus,

    We do not support ColdFusion+Apache on CentOS 5.x. You can try configuring CF+Apache on RHEL 6.

    Thanks,
    Kavya

    ReplyDelete
  3. Kavya,
    I followed your instructions on Mac OS X. My previously working CF9 instances now point to the root of the cf install, and the CF10 instance also points to the root of the CF10 instance, ignoring the DocumentRoot directive. Have you seen this before? Any ideas as to how I might be able to proceed? As a side note, this worked fine on a Windows laptop, just not Mac.

    ReplyDelete
    Replies
    1. I uninstalled the beta version and did a fresh install of CF10 and it is now working. Not sure if it was due to the beta version or some other configuration, but its working, and that makes me happy. Thanks!

      Delete
  4. Its really a nice post, the content of this blog is really awesome and extraordinary.And also please Read link bvba Woodstone which provide information server monitoring & monitoring tools

    ReplyDelete
  5. Nicely explained. Here you described the well written article from your in-depth knowledge. Truly impressive and nice information

    Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

    Java Online Training Java Online Training JavaEE Training in Chennai Java EE Training in Chennai

    ReplyDelete