Getting Coldfusion 10 With Mura, SES, and Virtual Hosts On Your Mac
Prerequisites
Thanks to two great articles by Rob Brooks-Bilson (http://rob.brooks-bilson.com/index.cfm/2012/2/23/Configuring-Multiple-Instances-of-ColdFusion-10-with-Apache-Virtual-Hosts), it's now pretty easy to get set up with using ColdFusion 10 with your local Mura development, while virtually mirroring what you're going to have on your live production server (i.e. SES settings, etc.).
Install Notes
If you're working from scratch, and haven't actually installed ColdFusion 10 yet, then take a look at Rob's installation instructions here: http://rob.brooks-bilson.com/index.cfm/2012/2/21/Installing-ColdFusion-10-with-Apache-on-Windows. Granted that this is for a Windows setup, but the Mac setup is virtually the same with the exception of your Apache file locations. His post was also on a Beta version, which has one less variable than the public and/or Mac version requires. The three variables needed for Apache as our web server are as follows (on my MacBook Pro anyways):
- Apache Configuration Directory - /private/etc/apache2
- Apache Bin File (Named differently in the installer but should be filled for you) - /usr/sbin/httpd
- Apache Server File (Named differently in the installer but should be filled for you) - /usr/sbin/apachectl
Virtual Host Setup
If you've got these all set up, then from looking over Rob's second blog posting on configuring multiple instances of Coldfusion 10, you'll notice that CF adds an include file to the bottom of your /private/etc/apache2/conf/httpd file. That file is called "mod_jk.conf", and will be the primary file for us to set up our virtual hosts.
You'll also notice in that directory that CF created a backup of your original httpd file, in the event that something goes wrong.
Go ahead and open that file in your favorite editor. The very end of the code should look like this:
<Files ~ ".hbmxml$"> Order allow,deny Deny from all </Files>
Type in a few spaces to give your self some good reading room, and create your virtual host as follows:
<VirtualHost *:80>
ServerName mydomain
ServerAlias
DocumentRoot /Users/MYUSERROOT/Sites/mysite
DirectoryIndex index.cfm
ErrorLog /private/var/log/apache2/mydomain-error_log
CustomLog /private/var/log/apache2/mydomain-access_log common
JkMountFile "/Applications/ColdFusion10/config/wsconfig/1/uriworkermap.properties"
<Directory "/Users/MYUSERROOT/Sites/mysite">
Options Indexes FollowSymLinks
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
RewriteEngine On
RewriteOptions Inherit
</Directory>
Alias /CFIDE "/Applications/ColdFusion10/cfusion/wwwroot/CFIDE"
<Directory "/Applications/ColdFusion10/cfusion/wwwroot/CFIDE">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^([a-zA-Z0-9/-]+)$ /default/index.cfm%{REQUEST_URI} [PT]
</VirtualHost>
For those of you that know Apache, this will be straightforward, but for those of you that don't, just copy and paste this for now, and let's review what we have:
ServerName
This can be anything you like. I really like having separate domain names per site that I'm working on; it just seems more realistic to me, as that's how they'll be when they go live. Should only contain one name: mysite, mysite.com, mysite.local, etc, but pick one and stick with it.
ServerName mydomain
IMPORTANT! Whatever you decide for your ServerName, you must make sure that it is also listed in your hosts file, which you'll find in /private/etc/. Simply open up the "hosts" file, and add a new line for it like so: 127.0.0.1 mydomain
ServerAlias
Refers to a list of any other domains you'd like to have on this. For example, www.mysite.com and mysite.com are in fact two different ServerNames, so any additional domains you want to link back to the primary ServerName, you'll have to put in to ServerAlias.
ServerAlias www.mydomain mydomain.com mydomain.net
IMPORTANT! Notice there are no commas? Each alias should be separated only by a space. The same is true for you hosts file: separate each domain by a space.
DocumentRoot
This is the path of where your site files live, and you're telling Apache and CF where to find them, even though they are outside of CF10's wwwroot.
DocumentRoot /Users/MYUSERROOT/Sites/mysite
IMPORTANT! Remember, that this is a site by site instance. Each virtual host should have its own site path, which is where all your Mura files will live.
DirectoryIndex
This will just tell Apache that the index file should be index.cfm.
DirectoryIndex index.cfm
Logs
These are useful for any logging information specific to the domain. Helps from having to sift through logs and find out information for a particular site. Just be sure to add in the domain for easy finding.
ErrorLog /private/var/log/apache2/mydomain-error_log CustomLog /private/var/log/apache2/mydomain-access_log common
JkMountFile
This is the file that gets included, and will make for SES capability for your MURA instance. We'll talk about that below, but this is where it includes this file when CF10 boots up.
JkMountFile "/Applications/ColdFusion10/config/wsconfig/1/uriworkermap.properties"
Site Directory
Unless you know what you're doing, the only update you'll to make is making sure your site path is set in the first code block.
<Directory "/Users/MYUSERROOT/Sites/mysite"> Options Indexes FollowSymLinks AllowOverride AuthConfig FileInfo Order allow,deny Allow from all RewriteEngine On RewriteOptions Inherit </Directory>
IMPORTANT! This is where you can set up any special settings for your site path.
Alias
This simply creates a quick alias to your CFIDE folder back in your CF10 directory, so that we can then access the CFIDE when using your new virtual host by simply going to mydomain/CFIDE/administrator to get to your admin on any virtual host!
Alias /CFIDE "/Applications/ColdFusion10/cfusion/wwwroot/CFIDE"
Alias Directory
Just as you do with your Site Directory, you have to tell Apache more about that directory, and any other special requirements you want it to have. Again, if you don't know what you're doing, simply copy the code.
<Directory "/Applications/ColdFusion10/cfusion/wwwroot/CFIDE"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory>
Mura SES Rewrites
Alas, we're at the end of the virtual host set up, and we're simply going to rewrite any urls that have our sitename and index.cfm in them. If you're not using SES in Mura (i.e. you don't have siteidinurls=0 and indexfileinurls=0 in your /murasite/config/settings.ini.cfm file), then you can simply leave this out. But if you are this will simply say any time that a request comes in for mysite/somepage, then have Apache take care of the mysite/index.cfm part of it. All that you need to do is put in whatever name you used when you set up your Mura instance. By default, Mura will create a default site, and call it.... that's right: "default". If you're using this as your site, then simply leave the code above as /default/index.cfm. But if you've created a new one, then change the code below to reflect the sitename.
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^([a-zA-Z0-9/-]+)$ /MYDOMAIN/index.cfm%{REQUEST_URI} [PT]
IMPORTANT! This will handle on the Apache side, but you still need to tell ColdFusion about the changes, so it can have Tomcat do the rewrites also.
Last Step
Now that we have all of our Apache dialed in, we need to tell ColdFusion, to tell Tomcat about our SES requests. You do this in the uriworkermap.properties file, which is found in /Applications/ColdFusion10/config/wsconfig/1/ directory.
Open that file, and go to the last line: 24 for me. Then, you simply map your sitename and index.cfm to this CF10 instance (as you can have more than one). Like so:
/sitename/index.cfm/* = cfusion
Restart
Now all we have to do is start or restart ColdFusion and Apache. Fire up terminal, and add this:
cd /Applications/ColdFusion10/cfusion/bin sudo ./coldfusion stop Wait for it to stop sudo ./coldfusion start Wait for it to start sudo apachectl -k graceful
Test
Now open up your browser, and enter your domain. If all is set correctly, then you should now be seeing your Mura site or CF Admin if that's what you tried first.
Let me know if you're having any problems or suggestions for improvements. I hope someone finds this useful, as it too me about 4 blog entries and about 5 hours of trial and error to finally get it working.
Please note that CF10 is not officially supported by Mura as of this date.