While setting up my Macbook Pro for web development, I was flummoxed by the issues reported by many people trying to setup ColdFusion 10 on OSX 10.8 Mountain Lion, as well as Window 8. Adobe even has a pre-release program to test new installers for both. I can understand having problems with Windows 8, but installing on OSX 10.8 couldn't have been easier.

Stop that, do this: OSX

Other than my iPhone 4S and iPad (the first one), I haven't had an Apple computer since my brother and I shared an Apple IIe back in grade school. BTW, that computer still works.

Apple IIe still working.

I know some people have issues using OSX when they've been in the Windows world for so long. One comment I saw told the poster to "stop thinking in Windows and start thinking in Unix." Best advice you can get.

I've used BSD, Unix and Linux (CentOS, Red Hat, Ubuntu) for around 15 years, so OSX can't be to difficult, right?

Install Java

This was probably the easiest time I've ever had installing Java. I'd installed a 256 GB SSD and a fresh install of Mountain Lion. The original hard drive had a previous version of OSX and Java was already installed. I wasn't sure if OSX came with Java pre-installed, so I opened up a Terminal, typed "java -version" and hit enter.

OSX responded like Crush from Finding Nemo: "Yo dude, I know you want to see which Java I have. Sorry bro, don't have it. I could, you know, get it for you if that's cool. Yeah? Awesome. Just hang loose a minute." And then, BAM! Java's installed.

Get Apache up and running

OSX ships with Apache pre-installed. With Mountain Lion, Apple changed how Apache is controlled through the System Preferences. Having never used a previous version of OSX, who cares? Let's proceed.

Apache can (and should) be controlled via the command line, same as with any *nix operating system, by using "sudo" commands. The first time you call one of these commands, you'll get prompted for your password.

view plain print about
1// Start
2sudo apachectl start
3
4// Stop
5sudo apachectl stop
6
7// Restart
8sudo apachectl restart

You'll get used to using "sudo" as you get more familiar with Unix. Even when you're not actually using Unix. (Image courtesy of http://xkcd.com/.)

One Apache is started, you can go to http://localhost or http://127.0.0.1 and you should see the message "It works!".

Installing ColdFusion 10

If you haven't installed ColdFusion before, it's pretty simple. Simon Free has some excellent instructions and videos over on "Learn CF in a Week". I also tried Wil Genovese's instructions for CF10 on Mountain Lion, but he uses a "non-Apple way", which I couldn't get to work. For a moment, I considered installing CF10 on MAMP, but I saw something shiny out of the corner of my eye and got distracted.

What was I talking about?

Oh yeah.

You can download the ColdFusion installer from the Adobe website. You'll have to create an account if you don't already have one to get the installation file.

Simon's instructions tell you to use the built in web server, but we want to use Apache. Also, don't set CF to start automatically when OSX starts. You only want CF running when you want it running.

  1. Open Finder > Downloads > double-click the ColdFusion_10_WWEJ_osx10.dmg file.
  2. Introduction: Next
  3. License Agreement: Accept : Next
  4. Install Type: Developer : Next
  5. Subcomponent Installation: Uncheck "Start ColdFusion on system init" : Next
  6. Enable Secure Profile: Not for local development : Next
  7. Remote Admin Credentials: Meh, not for local development : Next
  8. Select Installation Directory: Use the default, "/Applications/ColdFusion10" : Next
  9. Earlier Versions of CF: BORED! : Next
  10. Configure Web Servers: Click on Add
    The configuration directory for Apache on Mountain Lion is "/private/etc/apache2". This is key!
  11. You should now see this configuration listed : Next
  12. Configure Open Office: I tried to configure Libre Office, but it didn't work. Skip this unless you need Open Office.
  13. Admin Password: Something simple for local development : Next
  14. Enable RDS: Only if you want to integrate with ColdFusion Builder and other remote access. Not for Production servers. : Next
  15. Server Updates: Yes, please! : Next
  16. Current User Password: This was surprising, but should have been expected. I've never seen this on any Linux installation before. Since I'm not using the built in webserver, I think CF needs to "sudo" to alter the Apache configuration file. This would also have been needed if I had elected to start CF when OSX starts.
  17. Admin Password: Something simple for local development : Next
  18. Pre-installation summary: Next
  19. Installation Complete: Launch the Configuration Wizard @ http://127.0.0.1/CFIDE/administrator/index.cfm

    This will finish configuring ColdFusion and log you into the CF Admin.

Manage ColdFusion from the Terminal

Starting and stopping ColdFusion from the terminal is very similar to Apache.

view plain print about
1// Start
2/Applications/ColdFusion10/cfusion/bin/coldfusion start
3
4// Stop
5/Applications/ColdFusion10/cfusion/bin/coldfusion stop
6
7// Restart
8/Applications/ColdFusion10/cfusion/bin/coldfusion restart

Chris Simmons shows a few more helpful commands in this blog post.

OSX Sites

Referring back to the cnet article, you can configure a Sites directory in your Home folder in order to develop multiple web sites/applications.

  1. Open the OS X Terminal utility (/Applicaitions/Utilities/)
  2. Create and edit an Apache user configuration file named after your user account by running the following command:
    sudo pico /etc/apache2/users/`whoami`.conf
  3. Copy the following text into the Terminal editor that opens, but be sure to change the "username" text to the short name of your user account:
    view plain print about
    1<Directory "/Users/username/Sites/">
    2 Options Indexes MultiViews
    3 AllowOverride All
    4 Order allow,deny
    5 Allow from all
    6</Directory>
  4. Save and close the editor by pressing Control-O followed by Control-X.
  5. Stay in Terminal and go to your home directory. Create a folder named "Sites", then create an "index.htm" file in that folder with the contents "I fight for the Users!".
  6. Start or re-start Apache to pick up these changes.
  7. You should be able to visit "http://localhost/~username/index.htm" and see the contents of the file you just created.
  8. Now create an "index.cfm" file in your Sites folder with this simple content:
    view plain print about
    1<cfoutput>#now()#</cfoutput>
  9. Visit "http://localhost/~username/index.cfm" and you should see the current time.

Now you have a web root folder for your development efforts and you've verified that ColdFusion can parse CFML files in your Sites directory.

Apache Virtual Hosts

Often you'll want to use a local domain like "http://test.site" instead of "http://localhost/~username/test.site". By enabling Virtual Hosts in Apache, you can create multiple websites with their own domain, pointing to different folders inside the Sites folder.

Rather than write the details here, I'll just point to this simple example I found which is a breeze to implement.

Start coding

Now that I have Apache, ColdFusion and ColdFusion Builder (see related entry) installed on OSX Mountain Lion. I just need some data stores. MySQL and MongoDB will be a good start.

If you have any questions, feel free to contact me via this website or on Twitter @iknowkungfoo.