Sep
9
09
Snow Leopard and ColdFusion

ColdFusion on Snow LeopardI recently came across a possible job opening that calls for ColdFusion experience. ColdFusion, for those of you who don’t know, is a server side programming language. It’s used to perform some logic on the server before you see a web page. If you’ve ever seen a page that ended in “.cfm”, then you have seen a ColdFusion page.

I have some experience with ColdFusion (during my Co-op/Internship at Computer Services, Inc.) and I currently use PHP (another server side programming language) on this site. Since that job is still a possibility (i.e. I’m still in the running) I knew that I needed to go back and have a visit with ColdFusion. Although I’ve used it and I know how it works, I’m still out of practice with it and I need to become familiar with it, once again.

Adobe charges a huge amount for ColdFusion. Luckily, they do offer a free edition for developers (hey that’s me!). I headed over to Adobe’s website and downloaded a copy of ColdFusion 9, which is currently in Beta. Originally, I intended to use a program called MAMP (Mac Apache MySQL & PHP) but after many failed attempts at getting it to work, I gave up on this solution. Instead, I decided to use the built-in Apache server under Mac OS X.

Now, every version of Mac OS X that I’m familiar with (Tiger, Leopard, & Snow Leopard) has a built-in Apache server. Simply go to System Preferences and look under Sharing. There you will see an option for Web Sharing. Let’s go ahead and make sure that’s enabled.
Enable Web Sharing

PHP Anyone?

If you want, now is a fine time to enable PHP on our Apache server. To do this, I used a program that offers a GUI to help with your Apache server. This program is called VirtualHostX. The program is free if you are only creating a couple of sites on your Mac, or $19 if you plan on using it a bunch. I’ve had this program since version 1, so I just went ahead and paid the $5 to upgrade to version 2. I absolutely love this program and recommend it to anyone who is doing development with the built-in Apache server under Mac OS X. This program will automagically enable PHP for you. But, if you want to stay free and don’t want to mess with this program, there is one file in particular that you need to edit to enable PHP. Go into Finder and press Command + Shift + G. Now type in

/etc/apache2

 

and hit return.

Now we need to edit the httpd.conf file. Look around line 115 for

#LoadModule php5_module libexec/apache2/libphp5.so

 

All we need to do is remove the ‘#’ from the front to uncomment this line. Now look around line 228 for:

<IfModule dir_module>
DirectoryIndex index.html
</IfModule>

Add “index.php” to the line “DirectoryIndex…” to make it look like this

DirectoryIndex index.html index.php

 

This tells Apache to look for .php pages and to open them up accordingly.

Now save this file and close it. Restart your Apache server by going back into System Preferences -> Sharing and uncheck Web Sharing, then check it again. Now you can test your web server by creating a test PHP page in the directory

/Users/macusername/Sites

 

where “macusername” is your user name on your computer. Now to open this page in your browser, go to System Preferences -> Sharing and highlight Web Sharing. To the right, you’ll see a link that says

Your personal website, in the Sites folder in your home folder, is available at this address:
 

By clicking on this address, you’ll be taken to the URL of your personal Sites folder (the directory given above). This is where you can find the PHP test page you created.

Now For ColdFusion

Start the ColdFusion installer by double-clicking on the installer that you downloaded from Adobe. I installed ColdFusion with the “Server Configuration” option. Go through the steps until you get to the part where you are configuring the web server. Click the “Add” button. In the next window, ensure “Apache” is selected. The only field I had blank was the “Configuration Directory” field. In this field, enter this

/etc/apache2

 

The other fields should be correct. If they are not filled in for some reason, here are what their values should be:

/usr/sbin/httpd
/usr/sbin/apachectl
 

The next screen asks for the install location for the ColdFusion administrator folder. I installed this directory in my Sites folder (under my home folder). I had to manually select this option, so click on “Choose…” and use this directory:

/Users/macusername/Sites

 

The next few screens should be self-explanatory.

At the end of the installation, the ColdFusion Administrator site will try to open up. For me, this did not work. The problem (as I found out) is your personal sites location in Mac OS X. Your personal URL on your Mac is something like

http://ipaddress/~macusername/

 

This gives ColdFusion a fit. Luckily, our Apache server has the ability to create virtual domains for us. This allows us to change all that “ipaddress/~macusername” garbage to something like “macusername.dev”.

If you have VirtualHostX, this part is pretty easy and self explanatory. However, if you do not, it becomes a bit trickier. First, we need to add something to the httpd.conf file. This can be found in the directory

/etc/apache2

 

Around line 229, we need to add “index.cfm” to the DirectoryIndex options (much like we added “index.php” before). At the end of this file, add this:

NameVirtualHost *:80
Include /private/etc/apache2/extra/httpd-vhosts.conf
 

This enables us to create virtual hosts in our Apache server.

Now we need to edit the httpd-vhosts.conf file that can be found in this directory:

/etc/apache2/extra

 

In this file, add something like this:

<VirtualHost *:80>
ServerName “macusername.dev”
ServerAlias “www.macusername.dev”
DocumentRoot “/Users/macusername/Sites”
</VirtualHost>

Now, of course, macusername is our user name on your Mac. However, your URL doesn’t have to be the same as this example. I usually use the “.dev” at the end to indicate to myself that it’s a personal development site I’m working on, but feel free to use what you want.

All we have to do is restart Apache (by going into System Preferences, then Sharing, then uncheck and check Web Sharing). Then go to your browser and enter this in the address field:

macusername.dev/CFIDE/administrator/

 

and hit return. This will take you to your ColdFusion Administrator page (assuming ColdFusion is running; Run the ColdFusionLauncher in /Applications/ColdFusion9 to control your ColdFusion server).

Conclusion

I hope you have found this tutorial useful. I know I struggled with installing ColdFusion on my Mac for two days straight, so I thought I’d try to help any other Mac/ColdFusion developers out there. The only thing that I can really add to this is more love for VirtualHostX. This program is awesome and saves so much time, so I would definitely recommend this application for any Mac web developers. If you have any questions, feel free to comment or email me (from the about page). Or, if you have a sure fire way to get MAMP and ColdFusion running, let me know that as well. As I said at the beginning of this post, I was very unsuccessful with MAMP and ColdFusion. Until next time, enjoy that ColdFusion.

One Response to “Snow Leopard and ColdFusion”

  1. Thanks! Just what I was looking for.

    Eric, on December 25th, 2009 at 5:35 pm.

Leave a Reply