Web DevCenter    
 Published on Web DevCenter (http://www.oreillynet.com/javascript/)
 See this if you're having trouble printing code examples


ColdFusion MX on Mac OS X, Part 3

by Dick Applebaum
08/08/2002

Where We Left Off

In Part 2, we examined a simple program and the various environments in which ColdFusion MX can be used, including: Host, Developer, and User environments. We discussed the hardware requirements and we compiled a list of programs needed to install ColdFusion MX on Mac OS X. The required programs are:

This article assumes you have the requisite hardware; Mac OS X and VirtualPC installed; and Red Hat Linux and ColdFusion MX available.

What We Are Going to Do Today

We have a busy day planned--we are going to install a complete ColdFusion MX Integrated Development Environment, or IDE, on our Local Mac OS X operating system. We will perform these tasks:

Create a Mac OS X User to Run the ColdFusion MX Web Host Services

When we finish today's work, we will have an operational ColdFusion MX Web Host that we will use as part of our Local IDE. We will set up a separate Mac OS X user to run CFMX, so we can isolate it from other users. It makes sense to do all our installation and porting under the same user that will run the eventual system.

  1. With the System Preferences Users panel add a user named: cfmx. This user should have a Password and Administrative Privileges.

  2. Copy any disk files needed for Linux or ColdFusion installation to the:

    Users ==> cfmx ==> Public ==> Drop Box

    folder on the Mac hard disk. You do not need to copy any files you have on CD. The disk files needed are summarized above and are discussed in Part 2 of this series. Likely, the only file you need at this point is the CFMX Trial download.

  3. Log Out, then Log On as the cfmx user.

Create a Virtual PC Dropbox Drive

Author's Note: There are several ways to exchange files between a Virtual Machine OS and the Host Mac OS (OS X). The easiest is a technique called "Shared Folders". Unfortunately, there is no support for "Shared Folders" with a Linux VPC. There are ways that the Virtual PC and the host can exchange files through Networking (LAN or Internet). Here again, we are unfortunate--not all of you will have the necessary hardware or Internet configuration. So, we will use a Dropbox (similar to the above) which will work regardless of your configuration.

To create our Virtual PC Dropbox we will:

It's a little clumsy, but it works!

Here are the next steps you'll need to do:

  1. In the Finder, navigate to the folder that contains the downloaded CFMX Trial version install file. This folder is:

  2. Home ==> Public ==> Drop Box ==>
      cfmx_trial_linux_en

    Rename the download file to cfmxdnld.bin so it will be handled properly by DOS.

  3. Start VirtualPC (VPC) and select Window ---> Virtual Disk Assistant from the menu bar.

  4. The Virtual Disk Assistant window opens and the Select Operation page appears. Click on "Create empty floppy" or "Create hard disk image," then click on the right arrow.

  5. The New Disk Type page appears. Click on "Create hard disk image," then click on the right arrow.

  6. The New Hard Disk Location page appears. Click on the Select Drive Location... button.

  7. A Finder window appears. Enter VPC Dropbox as the "Save As" name. Browse to the desired location, for example, Documents, and click on the Select button.

  8. The New Hard Disk Location page is updated to show the drive name and location. Click on the right arrow.

  9. The New Disk Operating System page appears. Click on DOS, then click on the right arrow.

  10. The Hard Drive Capacity page appears. Use the following:

    Then click on the Create Drive button.

  11. The New Hard Drive Complete page appears. Click on the Done button.

Create a Virtual PC Machine to Run DOS

  1. From the Virtual PC List window, click on the New... button.

  2. The PC Setup Assistant window appears, and the PC Name page is displayed. Enter the Name of the new Virtual PC, for example, "DOS" and click on the right arrow.

  3. The Configuration Options page appears, click on "Guide Me," then click on the right arrow.

  4. The Operating System Selection page appears. Select DOS, click the right arrow.

  5. The Memory Settings page appears. Click No to accept the 32MB default, then click the right arrow.

  6. The Primary Drive Options page appears. Click Create a new drive image, then the right arrow.

  7. The Create Primary Drive - Choose Location page appears. Click the Select Drive Location button.

  8. A file Dialog appears. Enter the File name: VPC DOS. Browse to select a location for the drive, for example, Documents. Click the Select button.

  9. The Dialog disappears and the Create Primary Drive - Choose Location page is updated to show where the new drive will be created. Click the right arrow.

  10. The Create Primary Drive - Choose Drive Capacity page appears. The default is a dynamically expanding drive up to 2GB. Accept the default by Clicking the Create Drive button.

  11. The Create Primary Drive - Hard Drive Complete page appears. Click the right arrow.

  12. The Modem Settings page appears. Accept the default of No, and click the right arrow.

  13. The Palmtop Device Settings page appears. Accept the default of No, and click the right arrow.

  14. The Setup Complete page appears. Click the Done button.

Install DOS on the DOS Virtual PC Machine

  1. From the Virtual PC List window select the DOS VPC that we just created, then click the Startup button.

  2. The Virtual PC "DOS" window opens and it attempts to boot DOS. This fails because no operating system has been installed on the hard drive.

  3. A DOS floppy disk image is provided with the Virtual PC system. In the Finder navigate to:

    Applications ==> Virtual PC 5.x ==> 
    
        Extras ==> Installing Other OSes

    Within this folder there is a file named: PC DOS Boot Disk. Drag this file to the toolbar at the bottom of the Virtual PC "DOS" window. VPC will recognize this as a floppy disk image. The little floppy disk icon (third from the left) in the toolbar will be highlighted, and a small red down-arrow will light up when you are positioned correctly over the toolbar. Drop the file to capture the floppy disk image. Alternatively, you can accomplish the same thing using the Virtual PC menu bar: Drives ---> Capture Floppy image...

    Author's Note: You can drag the disk image over the little floppy disk icon or anywhere else on the toolbar. If you use the blank right side of the toolbar, you will see the name of the image you are capturing.

  4. From the Virtual PC menu bar, select: Control--->Restart

  5. A Dialog will appear asking if you want to restart the PC. Click the Restart button.

  6. The Virtual PC reboots from the floppy and asks if you want to install drivers on the C: drive and make it bootable. Enter Y.

  7. PC DOS is transferred (installed) onto the C: drive, along with the disk boot program. Close the Virtual PC "DOS" window.

  8. When the Shut Down Dialog appears, click Turn Off PC, then click the Turn Off button.

    Author's Note: It is very important to turn off the PC rather than save its status. This allows us to access the Dropbox drive from a different Virtual PC.

Put the ColdFusion MX Download File in the Virtual PC Dropbox

  1. From the Virtual PC List window, select the DOS Virtual machine. Click the Settings... button.

  2. The Settings for "DOS" window opens and the Current Settings panel appears. Click the Drive 2 icon.

  3. The Drive 2 Settings panel appears. Click Hard drive image radio button.

  4. A Finder window appears. Navigate to the VPC Dropbox drive you created above, for example:

    Home ==> Documents ==> VPC Dropbox

    Click on the Open button.

  5. The Finder window disappears and the Current Settings page is updated to show the Dropbox as Drive 2. Click the OK button.

  6. The Settings window disappears and the Virtual PC List window is displayed. With the DOS VPC still selected, click the Startup button.

  7. The Virtual PC "DOS" window opens and DOS is booted. In the lower left corner (fourth from the left), click the Folder icon and then click Shared Folders Settings.

  8. The Settings for "DOS" window opens and the Current Settings panel and the Shared Folders Settings panel appear. In the Shared Folders Settings panel, click the Share folder... button.

  9. A Finder window appears. Navigate to the folder that contains the CFMX Trial version installation file (which we renamed to cfmxdnld.bin in a previous step):

    Home ==> Public ==> Drop Box

    Use the following settings:

    Then click on the Share button.

  10. The Finder window disappears and the Current Settings page is updated to show the Shared Folder. Click the OK button.

  11. In the Virtual PC "DOS" window enter the following DOS Command:

    copy Z:cfmxdnld.bin D:

    Wait a few minutes for the CFMXDNLD.BIN file to be copied into the Dropbox drive. The DOS prompt will appear, indicating that the copy is complete. Close the Virtual PC "DOS" window.

  12. When the Shut Down dialog appears, click Turn Off PC, then click the Turn Off button.

    Author's Note: As before, it is very important to turn off the PC rather than save its status. This allows us to access the Dropbox drive from a different Virtual PC.

Create a Virtual PC Machine to Run Red Hat Linux

  1. From the Virtual PC List window, click the New... button.

  2. The PC Setup Assistant window appears, and the PC Name page is displayed. Enter the Name of the new Virtual PC, for example, "RH Linux 7.2" and click the right arrow.

  3. The Configuration Options page appears, click on Guide Me, then click on the right arrow.

  4. The Operating System Selection page appears. Select Linux, then click the right arrow.

  5. The Memory Settings page appears. Click Yes and drag the indicator to:

    Then click on the right arrow.

  6. The Primary Drive Options page appears. Click Create a new drive image, then the right arrow.

  7. The Create Primary Drive - Choose Location page appears. Click the Select Drive Location button.

  8. A Finder dialog appears. Enter the File name: VPC RH Linux 7.2. Browse to select a location for the drive, for example, Documents. Click the Select button.

  9. The File dialog disappears and the Create Primary Drive - Choose Location page is updated to show where the new drive will be created. Click the right arrow.

  10. The Create Primary Drive - Choose Drive Capacity page appears. The default is a dynamically expanding drive up to 15GB. Accept the default by Clicking the Create Drive button.

  11. The Create Primary Drive - Hard Drive Complete page appears. Click the right arrow.

  12. The Modem Settings page appears. Accept the default of No, and click the right arrow.

  13. The Palmtop Device Settings page appears. Accept the default of No, and click the right arrow.

  14. The Setup Complete page appears. Click the Done button.

  15. The PC Setup Assistant window will close and the Virtual PC List window will be displayed. With the Virtual PC RH Linux 7.2 window selected, Click the Settings... button.

  16. The Settings for "Virtual PC RH Linux 7.2" window opens and the Current Settings panel appears. Click the Drive 2 icon.

  17. The Drive 2 Settings panel appears. Click Hard drive image.

  18. A Finder window appears. Navigate to the VPC Dropbox drive you created above, then click the Open button.

  19. The Finder window disappears and the Current Settings page is updated to show the Dropbox as Drive 2. Click the OK button.

Install Red Hat Linux on the Red Hat Linux Virtual PC Machine

Important Author's Note: For our purposes in using the Linux installation to install and port CFMX it is important to follow these Linux Installation instructions exactly. The CFMX Linux package has some known issues if not enough disk space is available during installation. By following this procedure, you will avoid these issues.

  1. From the Virtual PC List window, select the RH Linux 7.2 VPC that we just created, then click the Startup button.

  2. The Virtual PC "RH Linux" window opens, and it attempts to boot. This fails because no operating system has been installed on the primary hard drive.

    Author's Note: You will notice that the cursor seems to become trapped within the VPC Linux window. This is because VPC uses an "Additions File" to handle the transition between the Virtual Machine's Windowing system and the Mac OS's windowing system. The "Additions File" is not available for the Linux VPC environment. (When you get a dialog requesting you to install this file, you can just ignore it.) To free the cursor from the VPC Linux window, just hold down the Command Key (Open Apple) while dragging the mouse out of the VPC Linux window.

  3. From the Finder, insert the first Linux CD into the drive and wait for it to spin up. Then drag the CD image to the toolbar at the bottom of the VirtualPC "RH Linux 7.2" window. The little CD Icon, second from the left of the toolbar, will be highlighted--a red down-arrow will appear. When the CD Icon is highlighted, drop the CD image (release the mouse button), and the CD will be mounted ("Captured") by the Linux VPC. Alternatively, you can capture the CD from the VirtualPC menu bar by selecting: Drives--->Capture Disc.

  4. From the Virtual PC menu bar, select Control ---> Restart.

  5. A Dialog will appear asking if you want to restart the PC. Click the Restart button.

  6. The Linux VPC will restart from the CD we just captured. After a few seconds the "Welcome to Red Hat Linux 7.2" screen will display. Hit the enter key and RH Linux will boot from the CD.

  7. After a while the Red Hat Linux Language Selection page appears. Use the default, "English", then click the Next button.

  8. The Keyboard Configuration page appears. Use the defaults:

    Then click on the Next button.

  9. The Mouse Configuration page appears. Use the default, ""3 Button Mouse (PS/2)", then click the Next button.

  10. The Welcome to Red Hat Linux page appears. Click the Next button.

  11. The Install Options page appears. Use the default, "Workstation", then click the Next button.

  12. The Choose Your Partitioning Strategy page appears. Use the default, "Have the installer automatically partition for you", then click the Next button.

  13. A dialog will appear, indicating that the partition table is unreadable and asks "Would you like to initialize this drive?". Click the Yes button.

  14. The dialog disappears and the Automatic Partitioning page appears. Use these defaults:

    Then click on the Next button.

  15. A "WARNING!! WARNING!!" dialog will appear, indicating that "You have selected to remove all Linux Partitions..." and asks "Are you sure you want to do this?". Click the Yes button.

  16. The dialog disappears and the Partitions page appears. This shows the Linux partitions you just created. Click the Next button.

  17. The Boot Loader Installation page appears. Use these defaults:

    Then click on the Next button.

  18. The GRUB Password page appears. Use the defaults:

    Then click on the Next button.

  19. The Network Configuration page appears. Use the defaults:

    Then click on the Next button.

  20. The Firewall Configuration page appears. Override the defaults:

    Then click on the Next button.

  21. The Language Support Selection page appears. Use the defaults:

    Then click on the Next button.

  22. The Time Zone Selection page appears. Select your time zone, then click Next.

  23. The Account Configuration page appears. Enter:

    Then click on the Add button.

  24. An Add a New User window opens. Enter:

    Then click on the OK button.

  25. The Add a New User window disappears, redisplaying the Account Configuration page. Click the Next button.

  26. The Selecting Package Groups page appears. Select KDE. Deselect all the others, then click the Next button.

  27. The Video Configuration page appears. Use the defaults:

    Then click on the Next button.

  28. The About to Install page appears. Click the Next button.

  29. The Installing Packages page appears. Installation proceeds automatically. It make take several minutes or several hours, depending on your computer.

  30. At some point, the CD will be ejected and an alert will appear, asking you to "Please insert disc 2 to continue". Insert the requested CD and wait for it to spin up, and then click the OK button. The dialog may be repeated several times before installation proceeds.

  31. The installation process resumes and proceeds until all packages are installed. Then the Boot Disk Creation page appears. Check the Skip boot disk creation checkbox, then click the Next button.

  32. The Monitor Selection page appears. Use the defaults:

    Then click the Next button.

  33. The Custom X Configuration page appears. Use the defaults:

    Then click the Next button.

  34. The Congratulations page appears. This indicates that the Linux installation is complete. Click on the Next button.

  35. The Installation Process exits and the Virtual PC is rebooted with the RH Linux system that you just installed. Let the boot continue and login as root with the password you assigned above.

    Wait a few moments and the system will start up the KDE graphical environment.

Install ColdFusion MX on Red Hat Linux

  1. From the KDE control panel, click the Shell icon located at bottom of the KDE window, third from the left (above the VPC toolbar).

  2. The Konsole window opens and a command line prompt is displayed--this is similar to the Mac OS X Terminal window. To see where our Dropbox Drive is located, enter:

    fdisk -l

    The resulting display will show our Dropbox disk is on device hdb1

  3. Next, we need to create a directory where we can mount the Dropbox. Enter:

    mkdir dropbox
    mount /dev/hdb1 dropbox
    ls -l dropbox

    The resulting display shows that our Dropbox contains one file, named: cfmxdnld.bin--the ColdFusion download file.

  4. We need to change permissions and execute the file. Enter:

    chmod 777 dropbox/cfmxdnld.bin
    dropbox/./cfmxdnld.bin

    The installation process starts and we see instructions for customization. To continue, hit Enter.

  5. Multiple pages of the license agreement will display. Hit Enter after each, to proceed to the next.

  6. When asked if you accept the license agreement, enter:

    Y
  7. When asked if there is a version of ColdFusion already installed, enter:

    N
  8. When asked for a serial number, enter:

    eval
  9. When asked where you would like to install ColdFusion MX, hit enter to accept the default:

    /opt/coldfusionmx
  10. When asked to select a Web server, hit enter to accept the default.

    Internal (Port-Based) Web Server
  11. When asked for a runtime user, enter the username we created during Linux installation:

    cfmx
  12. When asked for an Administrator Password, enter the same password you used when you set up the cfmx user during the Linux installation.

    yourpassword
  13. When asked for an RDS Password, enter the same password you used when you set up the cfmx user during the Linux installation.

    yourpassword
  14. When asked if you would like to install the Documentation and Example Applications, enter:

    Y
  15. When asked if you would like ColdFusion to start at System Boot, enter:

    N
  16. A Pre-Installation Summary is displayed. Review this for correctness. Hit back to return to any prior questions that need changing. When everything is correct, hit the Enter key to start the install.

  17. A progress bar is displayed, and the installation proceeds rather rapidly until it gets to the last mark -- this is where the bulk of the installation will be done.

    Author's Note: The installation process could take from 2 to 24 hours depending on the speed of your computer. To confirm that the installation is not hung up, watch the small hard disk icon at the bottom left of the VPC window. A little red light will periodically blink with disk activity. While this may seem like a long time for an installation, consider this: ColdFusion MX is completely self-contained and is installing everything it needs:

    All on an emulated Linux machine.

  18. Finally, the message appears saying that ColdFusion MX is now installed. Hit Enter to exit installation.

    Author's Note: At this point, you could run CFMX. Depending on your computer, the results could be unsatisfactory due to timing issues with emulating such a robust system. Our time will be better spent porting the installation to Mac OS X.

Put the ColdFusion MX Installation Files in the Virtual PC Dropbox

We are going to compress the entire CFMX installation and store it in the Dropbox as a single DOS file.

  1. In the Linux VPC shell, enter:

    tar -cvzf dropbox/cfmxinst.bin /opt

    The names of all the files being compressed will scroll through the display. After a few moments, the operation will complete and the command-line prompt will be displayed.

  2. Close the Virtual PC "RH Linux 7.2" window.

  3. When the Shut Down dialog appears, click Turn off PC, then click the Turn Off button.

    Author's Note: As before, it is very important to turn off the PC rather than save its status. This allows us to access the Dropbox drive from a different Virtual PC.

Transfer the ColdFusion MX Installation Files to Mac OS X

  1. From the Virtual PC List window select the DOS VPC, then click the Startup button.

  2. The Virtual PC "DOS" window opens and DOS is booted. In the lower left corner (fourth from the left), click the Folder icon and then click Shared Folders Settings.

  3. The Settings for "DOS" window opens and the Current Settings panel and the Shared Folders Settings panel appear. In the Shared Folders Settings panel, click the Share folder... button.

  4. A Finder window appears. Navigate to the folder that contains the CFMX Trial version installation file (which we renamed to cfmxdnld.bin in a previous step).

    Home ==> Public ==> Drop Box

    Use the following setup:

    Then click the Share button.

  5. The Finder window disappears and the Current Settings page is updated to show the Shared Folder. Click the OK button.

  6. In the Virtual PC "DOS" window enter the following DOS Command:

    copy d:cfmxinst.bin z:
  7. Wait a few minutes for the cfmxinst.bin file to be copied from the Dropbox drive. The DOS prompt will appear, indicating that the copy is complete. Close the Virtual PC "DOS" window.

  8. When the Shut Down dialog appears, click Turn Off PC, then click the Turn Off button.

    Author's Note: As before, it is very important to turn off the PC rather than save its status. This allows us to access the Dropbox drive from a different Virtual PC.

Acquire the gnutar Utility

We need to expand the cfmxinst.bin file that we compressed under Linux. We would normally use the corresponding tar command in Mac OS X. Unfortunately, the tar command is an older version (part of the Unix OS) that has some known deficiencies. One of these affects us: when expanding, tar will truncate any path names greater than 100 characters. Linux and some other Unix systems use a later version of tar named: gnutar. We need to acquire this program for Mac OS X.

If you have installed the Mac OS X Developer Tools, gnutar is already installed. To verify this, open the Terminal program, found in the folder:

Applications ==> Utilities

Enter:

ls -l /usr/bin/gnutar

If gnutar is present, you should see something like:

-rwxr-xr-x 1 root wheel 181532 Jul 12 04:27 /usr/bin/gnutar

If gnutar is not present, you could download and install the Apple Developer Tools from the Mac OS X Development Web site. Membership is free and you'll find lots of good resources there.

Alternatively, there is relational database management system named OpenBase, which is available for Mac OS X and includes gnutar. A free trial version is available at the OpenBase Web Site.

You can download and install OpenBase per the manufacturer's instructions.

Install ColdFusion MX on Mac OS X

We will now install a copy of the same ColdFusion MX system that we installed on Linux, onto Mac OS X.

  1. Open a Mac OS X Terminal window.

  2. We need to assume the identity of the root user to install the CFMX files: Enter the following, and your Mac OS X user password (when prompted):

    su root
  3. Make sure we are at the file system root level. Enter:

    cd /
  4. Expand the cfmxinst.bin file containing the entire ColdFusion MX Linux installation.

    Authors Note: The following commands can be entered on two lines, as shown, because the \ character preceding the newline, "escapes" the newline (makes it inoperative).

    If you have the Apple Developer Tools installed, enter the following:

    /usr/bin/gnutar -xvzf \
      /Users/cfmx/Public/Drop\ Box/cfmxinst.bin

    If you downloaded OpenBase, enter the following:

    /Library/OpenBase/bin/gnutar -xvzf \
       /Users/cfmx/Public/Drop\ Box/cfmxinst.bin

    The names of all the files being expanded will scroll through the display (notice the nice long path names). After a few moments, the operation will complete and the command-line prompt will display.

  5. Now, reassume the cfmx user identity, Enter:

    su cfmx
  6. ColdFusion MX for Linux ships with a developer version of the PointBase database system. It is used in the example programs and documentation code snippets. We need to make a copy of the PointBase driver and put it where the Mac OS X Java can find it. In the finder navigate (through our nice new CFMX installation) to:

    opt ==> coldfusionmx ==> runtime ==> 
      servers ==> lib

    Copy the PointBase jdbc driver: pbserver42RE.jar to

    Library ==> Java ==> Extensions

    You may see other items in this folder.

  7. We can't use the supplied shell script to start and stop CFMX because it launches an Intel C++ program. Instead, we have our own shell script, thanks to Christian Cantrell.

    Author's Note: Christian Cantrell is a Java developer who works with Flash and ColdFusion primarily as a hobby. He manages a team of Java/JSP programmers for a company called Amazing Media in Fairfax, VA. He does as much work as he can on his Mac (OS X exclusively). He is the co-author of Flash Enabled (New Riders) and is currently working on Flash Remoting, The Definitive Guide (O'Reilly) with Mike Chambers.

    Copy the shell script below into a text editor (I use BBEdit) and save it to:

    opt ==> coldfusionmx ==> bin

    as coldfusionosx

    Note: Make sure:

    #!/bin/sh
    
    # Set some environment variables.
    CF_DIR=/opt/coldfusionmx
    EX_DIR=/Library/Java/Extensions
    
    # Starts CFMX.
    function startColdfusion() {
      proc_id=`getProcess`
      if test $proc_id 
      then
        echo "CFMX is already running as process \
          ${proc_id}."
        exit 1
      fi
      echo "Starting CFMX..."
      #java -jar $CF_DIR/lib/cfusion.jar -start \ 
      #  default > $CF_DIR/logs/cfserver.log 2>&1 &
      java -jar $CF_DIR/lib/cfusion.jar -start \
        default &
      sleep 3
      proc_id=`getProcess`
      you=`whoami`
      echo "CFMX started by ${you} as process \
        ${proc_id} with extensions:" 
      cur_dir=`pwd`
      cd $EX_DIR
      for jars in `ls -1 *.jar`
      do
        echo "  - $jars"
      done
      cd $cur_dir
    }
    
    # Stops CFMX.
    function stopColdfusion() {
      proc_id=`getProcess`
      if test -z $proc_id 
      then
        echo "CFMX is not running."
        exit 1
      fi
      echo "Stopping CFMX..."
      kill -HUP $proc_id 
      sleep 3
      echo "CFMX stopped."
    }
    
    # Prints this command's usage.
    function usage() {
      echo "Usage: coldfusionosx start|stop|restart" 
    }
    
    # Returns CFMX's process id, if it's running. 
    function getProcess() {
      ps -auxww | grep "cfusion.jar -start default" \
        | grep -v grep | awk '{print $2}'
    }
    
    # Check to make sure we are on a Macintosh.
    if test `uname -p` != powerpc
    then
      echo "This script is for Macintosh OS X only."
      exit 1
    fi
    
    # Check to make sure an argument was passed in.
    if test -z $1
    then
      usage
      exit 1
    fi
    
    # Handle the command argument.
    if test $1 = stop
    then
      stopColdfusion
      exit 0
    elif test $1 = start
    then
      startColdfusion
      exit 0
    elif test $1 = restart
    then
      stopColdfusion
      sleep 5
      startColdfusion
      exit 0
    else
      usage
      exit 0
    fi
  8. Make the shell script executable. Enter:

    chmod 755 /opt/coldfusionmx/bin/coldfusionosx

Run ColdFusion MX on Mac OS X

Well, girls and boys, that time we have all been anticipating has finally arrived--it's Christmas in August!

  1. From the Mac OS X Terminal window, execute the shell script by entering:

    /opt/coldfusionmx/bin/coldfusionosx start

    Author's Note: You can also stop or restart CFMX by issuing the above command and substituting the parameter (last word) with the desired action.

    When you see the message: Server default ready, ColdFusion MX is running on Mac OS X!

  2. Open a browser and enter the following into the address bar:

    127.0.0.1:8500

    This is the Loopback address to our computer. :8500 is the port where the CFMX Default Web Server listens for requests.

  3. You will see an "Index Of" page with two items listed: Wow, that's really impressive!

    Actually, it is impressive, because it shows us that:

    are all running on your machine. What you are seeing is an "Index of" files in the Web root of a Web server. The index is displayed because there are no default Web pages currently installed in the Web root.

  4. Click on the CFIDE link and you will see another "Index Of" page.

  5. Click on the administrator link. You will see the CFMX Administrator login screen. This is it folks. This page, and any page from this point on, is being parsed and generated by the ColdFusion MX Web Application Server.

    Log in with the password you entered when you installed ColdFusion (on Linux).

  6. The Login screen disappears, and is replaced with a ColdFusion Administrator screen, followed by a "Welcome to ColdFusion MX" popup window.

  7. In the popup window select the Example Applications >> link.

  8. When the next page is displayed, select the Check for Applications on this server link.

  9. Experiment with the examples provided. Many of the examples use the PointBase relational Database Server provided with CFMX.

    Author's Note: A few things should be mentioned about performance:

    One: consider all that's going on: both ends of a Web application, the client (your browser), and the server or Web Host (Application Server, Web Server, Web Application Server, Database Server) are all running on the same machine along with the Internet protocol (Loopback Connection). You wouldn't run a production Web site configured this way. The components are all competing for resources. The Database Server, for example, would run on different CPU and hard disk matrix.

    Two: your machine is probably way under capacity (RAM, CPUs, Speed, Disk Speed, and so forth) to run a Web Host (not to mention a browser, and all the other applications you are currently running).

    Three: When a ColdFusion template (program) is first requested, it is retrieved from disk, parsed by the ColdFusion MX Web Application Server, then compiled into a Java (Virtual Machine) program, then translated into a Physical Machine program, then executed. ColdFusion MX has a sophisticated caching system, which allows much of this "Overhead" to be avoided for subsequent requests for the same template.

    Four: Some of the ColdFusion MX Services, graphing, for example, start up the first time a template requests the service.

    Five: Every CFMX Web page that you request is being requested for the first time and includes all the associated overhead. This overhead is noticeable (and acceptable) in a Local Integrated Development Environment (IDE), but would virtually disappear in a Production Web site that runs for months (years?) with thousands of hits to the same templates.

    Considering all the above, performance seems pretty good! With a little experimentation, I have found that CFMX performs as well as or better than PHP or Perl in a similar environment--but with a whole lot more to offer! You can experiment for yourself. Other articles at the O'Reilly Mac DevCenter discuss activation of some of the Web Host components available to Mac OSX -- Apache Web Server, PHP, Perl, MySQL, and so on.

  10. OK, we have one more thing to do--develop our own CF application. Remember our little phone list program from part 2 of this series? Let's use that! (It conveniently uses one of the databases included with CFMX.) In the Finder, browse to:

    opt ==> coldfusionmx ==> wwwroot

    You'll see three folders: the CFIDE and cfdocs folders we just saw when we opened our browser to 127.0.0.1:8500. The third, WEB-INF is a CFMX-internal folder that is not directly accessible from the Web. Create a folder named: mycfmxapps to hold your CFMX programs. Folders placed in wwwroot are Web folders, so avoid any spaces or special characters in their names.

  11. Below is our phone List program from part 2, with the first statement added to simulate receiving a request from a form on a prior Web page. Copy this program into a text editor and save it to our newly created mycfmxapps folder as PhoneList.cfm.

    <cfset Form.Department = "Sales">
    
    <cfquery name="getPhone" datasource="cfsnippets">
      SELECT    LastName, FirstName, Phone
      FROM      Employees
      WHERE     Department='#Form.Department#'
      ORDER BY  LastName, FirstName
    </cfquery>
    
    
    <h1>Department Phone List</h1>
    
    
    <table border="1" cellspacing="0" cellpadding="3">
      <tr>
        <th>Name</th>
        <th>Phone</th>
      </tr>
    
    <cfoutput query="getPhone">
      <tr>
        <td>#LastName#, #FirstName#</td>
        <td>#Phone#</td>
      </tr>
    </cfoutput>
    
    </table>
  12. In a browser window, enter:

    127.0.0.1:8500/mycfmxapps/PhoneList.cfm

    You should see the Department Phone List with dynamic content that was retrieved from a database.

Ta-Dah! We just met the objective that we set many weeks ago; we have a complete CFMX IDE running on Mac OS X!

Be sure and try the other example programs (as if I could stop you), experiment with the CFMX Administrator, review the online (to your local Web server) documentation.

Best of all--write and test your own CFMX Web programs entirely on your own Mac computer!

This is really slick! The Best Web Application Development System running on the Best Personal Computer with the Best Personal Computer OS.

Well, you've finally got your powerful new system installed and lots of exciting new things to explore. Enjoy!

In the next article, we will review and refine our CFMX Mac OS X installation. We will:

Dick Applebaum has been doing Web development since 1997, primarily with ColdFusion -- including his latest challenge to port ColdFusion MX to Mac OS X.


Return to the Web Development DevCenter.


Copyright © 2009 O'Reilly Media, Inc.