919 - 926 - 9847

How to configure a kick ass development setup - day 4

On our plate today, we'll be installing Apache.  I'm using the 2.2.x branch.

  • Go and grab your .msi, I'd recommend the one with OpenSSL included.  http://httpd.apache.org/download.cgi#apache22
  • Install Apache to c:\cf_dev\apache.  You'll need to choose "custom install" to change the directory. The other values can be left at default.
  • Get CF9 hooked up to Apache, Start-> All Programs-> Adobe-> CF9 xxxx-> Web Server Configuration Tool
  • Click Add... to create a new connector
  • Choose the CFusion instance and select Apache as your web server.  You'll need to pick out the configuration directory (c:\cf_dev\apache\conf) and the binary object (c:\cf_dev\apache\bin\httpd.exe) and check "install CF9 services".
  • Edit c:\cf_dev\apache\conf\httpd.conf and add at the bottom (the include pulls in any files we add to dev folder):
    #Turn on virtualhosts
    NameVirtualHost *:80
    NameVirtualHost *:443

    Include c:/cf_dev/apache/conf/dev/*.conf

    <Files ~ ".hbmxml$">
    Order allow,deny
    Deny from all
  • Find DirectoryIndex in the httpd.conf file, and add index.cfm to it.
  • Create a new site vhost file, we'll start with site1 (from back on day 1).  Create it as c:\cf_dev\apache\conf\dev\site1.conf
  • Fill it like so:
    <VirtualHost *:80>
    <Directory "C:\cf_dev\projects\site1">
        AllowOverride None
        Options None
        Order allow,deny
        Allow from all

    alias /CFIDE C:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\CFIDE
    alias /cfide C:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\CFIDE

     # JRun Settings
    <IfModule mod_jrun22.c>
        JRunConfig Verbose false
        JRunConfig Apialloc false
        JRunConfig Ignoresuffixmap false
        JRunConfig Serverstore "C:/JRun4/lib/wsconfig/1/jrunserver.store"
        JRunConfig Bootstrap
        AddHandler jrun-handler .jsp .jws .cfm .cfml .cfc .cfr .cfswf

     DocumentRoot "C:\cf_dev\projects\site1"
     ServerName site1.local
     ServerAdmin contact@localhost
  • Note, you should now remove all but LoadModule jrun_module "C:/JRun4/lib/wsconfig/1/mod_jrun22.so" from c:\cf_dev\apache\conf\httpd.conf.  This will allow us to use multiple J2EE engines under the same apache config.
  • Edit http.conf, and uncomment:
    LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
  • Create a Railo based site for Site2 (follow the steps found on day one to first create the site2 project), fill the c:\cf_dev\apache\conf\dev\site2.conf with (we use proxypass to hand of CFM requests):
    <VirtualHost *:80>
    <Directory "C:/cf_dev/projects/site2">
        AllowOverride None
        Options None
        Order allow,deny
        Allow from all

    <Proxy *>
                Allow from

    ProxyPreserveHost On
    ProxyPassMatch  ^/(.+\.cf[cm])(/.*)?$  ajp://localhost:8009/$1$2

     DocumentRoot "C:/cf_dev/projects/site"
     ServerName site2.local
     ServerAdmin contact@localhost
  • To make Tomcat aware of server, we need to add this just before the </engine> tag at the end of c:\cf_dev\tomcat6\conf\server.xml.  It seems like duplication, but it just MUST be done:
    <Host name="site2.local" appBase="webapps" unpackWARs="false" autoDeploy="false" xmlValidation="false" xmlNamespaceAware="false">
              <Context path="" docBase="C:/cf_dev/projects/site2" />
  • Edit your hosts file (mine is at C:\Windows\System32\drivers\etc\hosts) to locally route our requests to the correct place. site1.local site2.local

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
martin's Gravatar Hi Matt
This is brilliant! There are too few articles about Tomcat, Railo and ColdFusion so thanks for posting.

Could I add a few things for discussion?

1. I am more specific with which conf files I load. I separate out the connectors (eg what's between the <IfModule mod_jrun22.c> tags) into their own .conf files. SO I have a CF9.conf file, a railo.conf file and a cf6.conf file. That way I can fine tune each one and only load what is needed.
My local set up allows for patterns like
http://{project}.cf6/ etc..

2. Even though this is a dev environment I still restrict my CF admin access (more to separate & partition access + habit):
# allow general access to CFIDE
<Directory "C:/JRun4/servers/cfusion/cfusion-ear/cfusion-war/CFIDE">
AllowOverride None
Options None
Order allow,deny
Allow from all
# Restrict access to the administrator
<Directory "C:/JRun4/servers/cfusion/cfusion-ear/cfusion-war/CFIDE/administrator">
AllowOverride None
Options None
Order allow,deny
Deny from all

3. Would be to add wildcard hosting in my local Apache (more out of sheer laziness) eg:
<VirtualHost *:80>
      Include conf/extra/cf9.conf
      RewriteEngine on
      ServerAlias *.local
      VirtualDocumentRoot C:/www/%1/htdocs   

That way all I need to do for each project is add a new entry in my hosts file:
eg localhost local site1.local site2.railo

Thanks again for a great article.
# Posted By martin | 8/22/12 11:35 AM