My Perfect OS X Coldfusion Dev Environment - Installing Coldfusion 8 pt 2

>> Friday, 31 October 2008

Right in part 1 we installed CF 8 (woo hoo!) but before was can use it we need to do a few bits to get it working within apache because we opted to move the cifde folder outside of the default OS X webroot.

The plan for our development environment is to leave the default webroot alone and move all our sites into our development folder that sits within our user directory (/Users/{username}/Development/Sites/). We will use one site per dev project with additional ones being created for test/qa purposes should they be required. But before we can do any of this we need to enable virtual hosts in apache and create at least one site so we can attach the CFIDE folder to it and run the ColdFusion administrator.

So lets open terminal app and run the following commands...

$ cd /etc/apache2

$ sudo vi httpd.conf [enter password if prompted]

If you're unfamiliar with vi then you can learn the basics here or alternatively if you prefer to use a different text editor then feel free...

once you have the file open in the text editor locate the following line(s) and remove the # from before the include statement...

# Virtual hosts
#Include /private/etc/apache2/extra/httpd-vhosts.conf

so it looks like this

# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf

save and close the file

What that has basically done is enable a number of settings in the included file that turn on virtual hosts. however this file also includes some default virtual hosts that we do not want to use so we need to make some basic changes to the included file to remove these defaults and tell it where to find the configuration for our real virtual hosts.

$ cd extra

$ sudo vi httpd-vhosts.conf

comment out the two example virtual hosts by placing #'s at the start of each line from to like so...

# ServerAdmin
# DocumentRoot "/usr/docs/"
# ServerName
# ServerAlias
# ErrorLog "/private/var/log/apache2/"
# CustomLog "/private/var/log/apache2/" common

# ServerAdmin
# DocumentRoot "/usr/docs/"
# ServerName
# ErrorLog "/private/var/log/apache2/"
# CustomLog "/private/var/log/apache2/" common

add a line at the bottom of the file like this...

Include /private/etc/apache2/vhosts/*.conf

save and close the file
$ cd ../

$ sudo mkdir vhosts

$ cd vhosts/

Now we will create the virtual host configuration for our default site, this will use the machine name you chose in this post mine is badapple so my default site is BadApple.local simply replace all instances of BadApple in the following code with your own machine name.
$ sudo vi badapple.local.conf
then into the file insert the following (remember to replace badapple with your own machine name!)

ServerAdmin webmaster@badapple.local
DocumentRoot "/Users/Ciqala/Development/Sites/badapple.local/webroot"
ServerName badapple.local
ServerAlias www.badapple.local
ErrorLog "/private/var/log/apache2/badapple.local-error_log"
CustomLog "/private/var/log/apache2/badapple.local-access_log" common

DirectoryIndex index.cfm index.html index.htm

<Directory /Users/Ciqala/Development/Sites/badapple.local/webroot>
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all

# JRun Settings (cfusion server instance)


save the file but leave it open. spawn a new terminal window and run the following command...

$ sudo vi /etc/apache2/httpd.conf

go to the end of the file and you should see something like this...

LoadModule jrun_module /Applications/JRun4/lib/wsconfig/1/
JRunConfig Verbose false
JRunConfig Apialloc false
JRunConfig Ignoresuffixmap false
JRunConfig Serverstore /Applications/JRun4/lib/wsconfig/1/
JRunConfig Bootstrap
#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

copy this and paste it into the other terminal window directly under the comment...
# Jrun Settings (cfusion server instance)

save the file and then go back to window with httpd.conf open and remove the code you just copied. this is so that our default jrun/cf instance only runs inside our default site and doesn't cause any conflicts with the other sites we create later that may use another jrun instance. make sure everything is saved and closed then run the following command...
$ sudo apachectl -S

this tests the virtual host configuration is valid, if all looks ok then we need to restart apache so it is aware of these new changes.
$ sudo apachectl graceful-stop

$ sudo apachectl start

now fingers crossed if you browse to http://{machinename}.local/CFIDE/administrator/ you should successfully see the cf administrator (and as this is the first time using it you will have a quick wizard run to set things up)

If this works you now have a valid coldfusion install and any code placed into the default sites webroot should run just fine.

In the next post I'll take you through installing MySQL so we can starts to store some data in our apps.

If you have any problems with the contents of this post please post a comment and I'll do my best to help you out. alternatively you can drop me a message on Twitter using the button on the top left of this page.


Michael 25 November 2008 at 18:17  

I'm sure all will be revealed in later posts but I'm just wondering why you set things up this way and not use the default sites folder and vhosts file?