Web DevCenter
oreilly.comSafari Books Online.Conferences.
MySQL Conference and Expo April 14-17, 2008, Santa Clara, CA

Sponsored Developer Resources

Web Columns
Adobe GoLive
Essential JavaScript

Web Topics
All Articles
Scripting Languages

Atom 1.0 Feed RSS 1.0 Feed RSS 2.0 Feed

Learning Lab

ColdFusion MX on Mac OS X, Part 2

by Dick Applebaum

Editor's note -- In Part 2 of this multipart series, Dick Applebaum digs deeper into ColdFusion MX as he works toward setting up this Web development environment to run on Mac OS X. First he shows you a simple example of ColdFusion code. Then he outlines ColdFusion's role in various Web scenarios, such as host, developer and user environments. The article concludes with a step-by-step preparation list for Part 3, which will cover the actual installation on Mac OS X.

In Part 1, we reviewed the features and benefits of ColdFusion and its evolution. We finished with a brief overview of several important features of the latest release, ColdFusion MX.

A Brief ColdFusion Review

ColdFusion is a popular and capable Web application development system. With ColdFusion you can rapidly (and inexpensively) develop, deploy, and maintain sophisticated, state-of-the-art Web sites.

Through the use of powerful tag commands, ColdFusion developers can easily integrate programming logic and database output to generate content that can be merged with presentation logic (HTML, Java, JavaScript, Flash, and so on) to render a dynamic page--one that is customized to a specific user's request.

Example of a ColdFusion Program

The following example queries the database and returns the name and phone number for all employees in a requested department. (The department was entered into a form on a prior Web page.) The records are sorted by Last Name, then First.

The database query is performed by the ColdFusion <cfquery>...</cfquery> tag. After retrieval, the records will be displayed in a table, with one row for each record. The ColdFusion <cfoutput>...</cfoutput> tag iterates over the selected records displaying one table row for each record.

The <cfoutput>...</cfoutput> tag is conditioned to use the data retrieved by the <cfquery>...</cfquery> tag by specifying the QueryName. The example also illustrates how ColdFusion can intermingle program statements (CF Tags), page layout statements (HTML tags), and dynamic data (CF Variables shown as #VariableName#).

<cfquery name="getPhone" datasource="cfsnippets">
  SELECT    LastName, FirstName, Phone
  FROM      Employees
  WHERE     Department='#Form.Department#'
  ORDER BY  LastName, FirstName

<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>
Figure 1. Department phone list
Figure 1. Department phone list

ColdFusion acts as a programmable preprocessor, substituting program results and data for the CF tags. Even in this simple example, you can see the power of ColdFusion. With two simple commands we're able to generate a dynamic page from a database. But that's only part of the story. ColdFusion programs tend to be self-documenting, and can be easily read, understood, and maintained over the life of the program.

What Is ColdFusion's Role in a Web Site?

To understand where and how ColdFusion is used in Web publishing, I need to define some terms so we're all talking about the same things. A typical Web site operates in one environment, is developed in a second environment and is accessed from a third. I'll take you on a brief stroll through each of these scenarios.

Web Host environment

A typical Web Host consists of multiple machines, running multiple programs or services that comprise a Web site. The basic programs and services are:

  • A Web Sever.
  • A Web Application Server.
  • A Database Server.
  • An Internet Connection.

Figure 2. A typical Web Host environment
Figure 2. A typical Web Host environment

Here's how this process works from the bottom up:

  • The Web Host is connected to the Internet via communication facilities that we'll call the Internet Connection.
  • The Internet Connection can include combinations of low and high-speed telephone, wireless, cable, direct-wire and satellite transmissions
  • The Web Server handles all incoming requests. If the request is for a static Web page, the Web Server retrieves the necessary Web Page Files (HTML, images, etc.) and returns them to the requestor.
  • If the incoming request is for a dynamic Web page (one involving programming), the request is passed to the Web Application Server.
  • The Web Application Server retrieves and executes the Program Files necessary to satisfy the specific request for a dynamic page.
  • During execution of the Program the Web Application Server may make requests of a Database Server for any dynamic data needed. In our earlier example: the Program requested the name and phone number of every employee in a specified department.
  • The Web Application Server may also retrieve Web Page Files and combine them with the Program results and Database data to dynamically generate the requested page.
  • The Web Application Server returns its results to the Web Server for return to the requestor.

The Web Host environment is where ColdFusion is installed to run "Production" Web sites. In this environment ColdFusion assumes the role of a Web Application Server. Third-party products are normally used for the roles of Web Server and Database Server.

What is ColdFusion's role? In the Web Host environment it is a "Production" Web Application Server.

Web User Environment

The interaction described above is initiated by the simple act of someone, a Web User, entering a request for a Web page into a browser.

The Web User may be miles (or even continents) distant from the Web Server.

Figure 3. Web User Environment
Figure 3. Web User Environment

  • The Web User enters the desired site's Web address (URL) or clicks a link containing the URL.
  • The Web User and the Web Host are connected via the Internet Connection.
  • The Web Server receives the request, processes it (passing it to the Web Application Server where necessary), and returns the results as described above under Web Host.

What is ColdFusion's role? ColdFusion has no direct role in the Web User environment.

Remote Web Developer Environment

A Remote Web Developer also needs to access the components at the Web Host.

For purposes of testing, the Remote Web Developer will act as a Web User and connect to the Web Host to retrieve pages and run programs in the normal manner.

The Remote Web Developer is also responsible for the programs and Databases that run at the Web Host.

The Remote Web Developer's access to the host requires some additional interfaces.

Figure 4. Remote Web Developer Environment
Figure 4. Remote Web Developer Environment

The Remote Web Developer environment includes a set of tools (often with a GUI), which allow the developer to create and maintain:

  • HTML Pages.
  • Image, sound, movie, etc. files.
  • Program Functions to be downloaded with a web page and executed on the Web User's machine (Java applets, JavaScript programs, Flash Action scripts, etc.).
  • Programs Files to be executed at the Web Host .
  • Database data and stored procedures.

It's important to note that these Developer Tools run on the local machine and manipulate the components of the Web Host through the Internet Connection.

What is ColdFusion's role? ColdFusion has no direct role in the Remote Web Developer environment. However, many Developer Tools are "ColdFusion Aware" in that they recognize ColdFusion tags, structure, and language syntax.

Local Integrated Development Environment (IDE)

For many reasons, it would be nice if we could duplicate all these environments: Web Host, Web User, Web Developer; and place them in a single computer and make them interact with each other in a Local Integrated Development Environment. A few of the advantages are:

  • We wouldn't need to connect to the Internet. We could write and test our Web applications without experiencing the downtime, phone line delays, and Internet traffic tie-ups.
  • We could observe "both ends" of an application during testing to help detect undesired side effects, such as spiking of server resources, resource lockouts, and deadlocks, etc.
  • We would be free to make additions and changes, knowing that they would not affect the "Production" Web Host site, until we were ready to deploy them.

This Local IDE would be self-contained. If it were installed on a laptop, we would have a complete, portable system that we could use anywhere.

Figure 5. Local Integrated Development Environment
Figure 5. Local Integrated Development Environment

The Local IDE environment is very similar to the Remote Web Developer environment. The major differences are:

  • Everything resides on a single machine
  • The Internet Connection has been replaced with a Loopback Connection.

The Loopback Connection is just a special mode of the standard communication protocol used on the Internet. By using special URL addresses, we tell each component to look for other components on the same machine (or Local Area Network) instead of on the Internet. So, once we have all the programming installed on our local computer, all we need do is use a Loopback URL address to develop and test locally. Conversely, whenever we want to access the "Production" Web Host, we use normal Internet URLs.

An Internet URL might look like this:


The corresponding Loopback URL:


Another difference is that the emphasis in the Local IDE environment is on function, rather than performance. This means that many of the components need not be as robust (or as expensive) as they would be in a "Production" system. For example the Local IDE might contain a reduced-performance/capacity, full-function Web Server, Web Application Server, and Database Server.

What is ColdFusion's role? ColdFusion plays a major role in the Local IDE environment. It provides a very efficient and economical representation of the entire WebHost environment.

Self-Contained Product

The ColdFusion MX product is self-contained -- it includes everything you need to represent the Web Host environment on a local machine:

  • Web Server*.
  • ColdFusion Web Application Server.
  • Database Server*.

* Note: Use of the ColdFusion-supplied Web Server and Database Server is optional. You may use any supported third-party products in their place.

Any current browser can be used for the Web User Environment.

You can purchase integrated Web Developer tools such as Macromedia Dreamweaver MX, or use separate page editors, FTP tools and Remote Access tools from several sources.

For our purposes, we will concentrate on installing ColdFusion MX as the Web Host portion of the Local IDE.

What is ColdFusion's role in a Local IDE? ColdFusion provides an equivalent of a complete Web Host environment on the local machine.

Related Reading

Programming ColdFusion
By Rob Brooks-Bilson

Preparing to install ColdFusion MX on Mac OS X

A CFMX Trial version is available from Macromedia at no charge. Actually, the Trial version is a full-feature ColdFusion MX package that runs for 60 days. After 60 days, you can activate a production system by purchasing and entering a serial number. If you do not "activate" the system, it reverts to Developer mode where it supports access from a single web IP address only. Thus, the system can be used for development, but cannot be deployed as a Web host.

CFMX runs on several platforms, alas, Mac OS X isn't among those available. However, CFMX is written in Java. In theory, it should run on any platform, which supports the required Java system. Every Mac OS X release includes the requisite Java system.

This leaves us three choices:

  • Buy the hardware for a supported platform.
  • Emulate a supported platform.
  • Port a supported system to run Mac OS X native.

The first option does not meet our objective to run ColdFusion MX on OS X. While emulation is possible, it's less than ideal for serious development. Our goal is to get a ColdFusion development environment running native on Mac OS X.

In the next article, we'll explore how to install CFMX on a supported platform that can be emulated on Max OS X. Later, we'll port this emulated installation to native Mac OS X. We will use Virtual PC (VPC) from Connectix for emulation. VPC provides the Mac OS X user with the capability to emulate a PC, and run many of the popular PC operating systems (OS's). There's a price for VPC, but it is one that most Mac Web developers have already justified with the need to test their Web sites with browsers running on Mac, Windows, and Linux/Unix machines.

CFMX is currently available for Windows, Linux, Solaris, and HP-Unix. Of these three, VPC provides emulation for Windows and Linux. You could install ColdFusion MX for either or both. We'll install the Linux version of ColdFusion MX -- Linux and Mac OS X have common ancestors (it will be easier to port to OS X).

What we will need:

  • A minimum 400MHz G3 or G4 Macintosh to run VPC.
  • A minimum 256MB RAM.
  • 2 Gigabytes of available hard disk space.
  • Mac OS X 10.1.4 or later.
  • Connectix Virtual PC version 5.02 with DOS (no other Connectix-provided OS is required).
  • Red Hat Linux version 7.2 or later.
  • ColdFusion MX Trial Release for Linux.

Preparation to Install CFMX on Linux VPC

  • Upgrade your OS to Mac OS X 10.1.4 or later.
  • Upgrade your Mac hardware as required.
  • Acquire and install Virtual PC with DOS from Connectix and install per manufacturer's instructions.
  • Acquire Red Hat Linux 7.2 or later available from the Red Hat site.-- I wanted a Linux reference as well as the software, so I visited my local bookstore and purchased a book, which included the RH distribution on 2 CDs.
  • Download the Trial release of ColdFusion MX for Linux from the Macromedia Web site.

Next Time

It may take you several days to gather the above components. This is a convenient place to pause and catch our breath for the job ahead. In the next article, we'll go through the detail steps to install and configure Linux on VPC. Then we will install and configure ColdFusion MX Linux in preparation for our port to Mac OS X.

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.