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 2

by Dick Applebaum
07/03/2002

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
</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>
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:

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 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

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:

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:

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:

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:

    http://www.somewebsite.com/myProgram.cfm

The corresponding Loopback URL:

    http://localhost/myProgram.cfm
or
    http://127.0.0.1/myProgram.cfm

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:

* 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:

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:

Preparation to Install CFMX on Linux VPC

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.

Copyright © 2009 O'Reilly Media, Inc.