Table of contents
21 March 2011
.User level: Beginning
Additional required other products
This tutorial gives you step-by-step instructions for setting up your ColdFusion development environment on Windows using an Apache web server. You will also learn how to set up ColdFusion Builder 2 as your editor. I have written this article for beginners to ColdFusion, thus, no prerequisite knowledge is required.
First, you will follow steps to install all the software elements for your ColdFusion development environment. This includes installing Apache as your web server, installing ColdFusion so that you can create and run dynamic applications, and installing ColdFusion Builder 2 to help you develop those applications.
To serve your web pages on the Internet you must install a web server. The Apache Web Server (also known as HTTPD) is free and open source, and used in many production environments due to the stability and flexibility that it offers web developers.
Download Apache and start the Apache Web Server Installer (as of this writing, the current version is 2.2.16). When the Apache installer starts, a Security Warning screen may appear (Figure 1). This is standard for applications downloaded from the Internet. Click Run to start installing Apache Web Server.
Figure 1. A typical security warning for applications downloaded from the Internet. Click Run
Click Next on the Apache HTTP Server welcome screen. As with all installers, the next screen asks you to read the software license agreement. To proceed, accept the agreement and click Next.
The install process next presents a Read This First screen. If you haven't used Apache HTTP Server, this information explains Apache web server, the latest version number and the installation steps. After reading this information, click Next.
Figure 2. The Read This First screen
The Server Information screen will show all the default settings, such as your computer name and your computer's assigned domain. The default settings are sufficient for your local development. When installing the server on a production machine, however, you may wish to change the settings to be more secure. You'll be able to get these details from your network administrator. The options at the bottom of the screen specify the port the server will be installed on. HTTP Servers are usually installed on port 80. If your windows machine has Internet Information Server installed already, it may already be using port 80, so there may get a conflict on port 80. If you install Apache on port 80, it may seem like Apache didn't install correctly. Once the installer has completed you can change the port in the HTTP configuration file so that Apache doesn't clash with another web server on the same port. (Also if you have Skype installed, you must not run it at the same time as this installation process, as Skype also runs on port 80 if nothing else is running on port 80 at the time it starts. If another software is using port 80 and Skype starts, it will select a different port number.)
Once you are happy with the settings, click Next.
Figure 3. Server Information
Select the Setup Type that best suit your development purposes. For the purposes of this article, select Typical and click Next.
Figure 4. Setup Type
On the Ready to Install screen, click Install to start the installation process.
Figure 5. Start the install process
Before the installer proceeds, you may get security warning informing you that the installer will make changes to your computer. If it's safe for Apache to make these changes, click Yes.
Figure 6. Allow Apache Installer to make changes
The Installer will copy over all the files you need. A few black command prompt boxes will appear as files and services are installed. Once the installer is complete, click Finish.
If a black command prompt informs you that Apache couldn't start because it couldn't find or use port 80, this could mean there is another process already using port 80. Again, check to see if IIS is already installed or if Skype is running. You can stop the IIS service or quit Skype, or change the port that Apache Web Server uses as follows.
- Open the HTTP Config file located at: C:/Program Files (x86)/Apache Software Foundation/Apache2.2/conf/httpd.conf. If you are running on a 32-bit platform, you may only have a C:/Program Files/ folder; Apache will be located in this folder.
- Search the file httpd.conf for the directory ServerName where you will see the domain entered in the installer followed by the port 80. You can change this port and save the file. Restart Apache.
- The Start Apache Monitor is located in the System tray at the bottom of the screen.
To see Apache HTTP Server running, load a web page served by Apache web server in a browser. If you are using Apache on port 80, you can simply browse to http://localhost. If you have your port set to 92, you must add the port number to the URL you are browsing, for example: http://localhost:92.
Figure 7. Confirming your Apache install
In this section, I explain how to install ColdFusion 9 followed by instructions on how to apply the ColdFusion 9.0.1 Updater to ensure that you have the latest edition of ColdFusion.
As with all software installers there is the License Agreement to read and accept before proceeding. For the purposes of this tutorial, you will install the ColdFusion Developer Edition, which is free and doesn't require a serial number. The limitation on the developer edition is that you can only have two unique IP addresses accessing the server and watermarks appear on some of the features.
Figure 8. Select the Developer Edition for your Install Type
You have three options to choose from for your installer configuration:
- Server Configuration
- Enterprise Multiserver configuration
- J2EE configurations
I suggest selecting Enterprise Multiserver configuration. By choosing this option, you can run multiple servers, each with a different configuration, which gives you the full benefit and power of the ColdFusion platform. Once you have selected the Enterprise Multiserver option, click Next.
Figure 9. ColdFusion Installer Configuration screen.
Next, you have the option to install ColdFusion subcomponents; to have the full power of the platform, leave all the options selected. When you install ColdFusion in your production environment, however, only install the components that are required. In production you shouldn't install the Documentation as this isn't required to run ColdFusion. Once you have selected your subcomponents, click Next.
Figure 10. Subcomponent Installation
You will then select the directory to install ColdFusion , unless you have a company or IT policy for the location to install new software, you can use the default location. If this is the case, click Next. If you have selected the .NET Intergration service, you will be asked for the directory to install it to.
In the next screen, select the Web Server that will connect to ColdFusion. Click Add.
Figure 11. Configure Web Servers for ColdFusion
You will then need to select the location of the configuration file for Apache and the Apache binary file. If you have selected the default installation for your Apache web server installation, the locations will be:
64 Bit Platform
- C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf
- C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin\httpd.exe
32 Bit Platform
- C:\Program Files\Apache Software Foundation\Apache2.2\conf
- C:\Program Files\Apache Software Foundation\Apache2.2\bin\httpd.exe
Once you have entered these details, click OK.
Figure 12. Configuring the Apache web server to connect with ColdFusion
Now the Apache web server is listed under the web servers (Figure 13). Click Next.
Figure 13. Apache is configured to work with ColdFusion
Using the data selected, the installer asks you to specify the location for ColdFusion 9 Administrator; the default location for this is the webroot for Apache. For the purposes of this article, I recommend that you leave the default settings. Click Next.
Figure 14. Specifying the ColdFusion 9 Administrator location
Enter a password to access the ColdFusion administrator. The password is required you cannot enter a blank password once you have entered your selected password. Click Next.
The install request whether you want to Enable Remote Development. You can enter a password. This can be different than the ColdFusion Administration password. You will need to remember this password when you connect ColdFusion Builder to your ColdFusion instance. Once you have enabled RDS and entered a password click Next.
Figure 15. RDS Password
The almost-final screen of the installer is the summary screen. Confirm all the options selected, then click Install.
Figure 16. Pre-installation summary screen
The installer will start. Once the installer has completed click the Done button and the ColdFusion Administrator will open.
Enter the password you entered in the installer for ColdFusion Administrator.
Figure 17. Configure ColdFusion login
ColdFusion Administrator will finalize the installation. Once complete, click OK. The ColdFusion Administrator will open indicating that the install is complete.
Figure 18. ColdFusion 9 Administrator
Next, you will install the ColdFusion 9.0.1 Updater. You will see the Windows Warning that the installation program will make changes to your computer, the quick introduction, and the license agreement. Click Next in all of these cases to proceed.
Select the install type. Select the same option selected in the main ColdFusion installer, which is in this case the Multiserver configuration. Click Next.
Figure 19. Updater Configure Installation
You must shut down all ColdFusion instances before proceeding. Using the Services interface stop the following services:
- Macromedia JRun Admin Server
- Macromedia JRun CFusion Server
Figure 20. Stopping ColdFusion services
Once the services have been stopped, you will then be asked for the location where you installed ColdFusion. if you selected the default settings in the main installer, leave the location as the default value and click Next.
Figure 21. Install Location
You will then be asked for the location of the CFIDE folder. Again if you selected the default options in the main installation, you can leave the default location and click Next.
Figure 22. ColdFusion Administrator location
The installer will then start. Once it is complete, the installation reviews the changes made in the Install Complete screen. Once you have read through this screen, click Done. Check that the install has installed fully by opening the ColdFusion Administrator, clicking the System Information button at the top right of the Administrator, and checking that the Version number is 9,0,1,274733.
Figure 23. Confirm new update version
Shortly after the release of ColdFusion 9, Adobe also released an IDE dedicated to ColdFusion based on the Eclipse Platform. Installing ColdFusion Builder 2 will help with all your ColdFusion development tasks.
When you start the ColdFusion Builder 2 installer, you may get the security warning that the application will make changes to your computer. Click Yes to proceed with the installation. The installer starts and shows you an introduction screen, click Next. The license agreement screen appears. If you agree with the license agreement, select the accept option, click Next.
You have two ways to install ColdFusion Builder 2:
- As an Eclipse plugin
If you don't have Eclipse or Flash Builder installed on your machine, select the Standard option. By selecting the Standard option, the installation will give you Eclipse, into which you can install additional plugins. If you have already installed Eclipse or Flash Builder, select the plugin option. (Note: You cannot run ColdFusion Builder 2 and CFEclipse in the same install.) For the purposes of this article, I suggest you select the Standard option.
Figure 24. ColdFusion Builder 2 install type options
Select the folder to install ColdFusion Builder 2 into. Unless you have a company policy/instructions from your IT department for the location to install new software, you can select the default location. Click Next.
Figure 25. Install folder
You can also associate .CFM and .CFC files to open with ColdFusion Builder 2 when you click those files in Windows Explorer. If you do not wish to have this feature, deselect this option and click Next.
Figure 26. Associate CFM and CFC files with ColdFusion Builder 2
The installer presents a confirmation page for you to review the options you selected. Check the information shown and when you are ready, click Install.
Figure 27. Install confirmation screen
Once the installer has completed, and ColdFusion Builder 2 will start. When ColdFusion Builder 2 starts for the first time, you will be asked for the location of your workspace. You can change the workspace to a location of your choice or leave as the default. You normally will want to use the same workspace every time, so select the option "Use this as the default and do not ask again".
Figure 28. Select Workspace
When ColdFusion Builder 2 starts you are prompted to enter a serial number, if you have one, enter it here, otherwise select the 60-day trial and click Next.
Figure 29. Software setup page, entering a serial number or selecting the 60-day trial version
Next, the installer asks you to sign into your Adobe Account. You can skip this or enter your Adobe ID if you have one. If you don't already have an Adobe ID you can easily create one here. When ColdFusion Builder 2 starts, it shows a start page that gives quick access to the features of ColdFusion Builder 2.
Figure 30. The ColdFusion Builder 2 workbench
Now that you have ColdFusion 9.0.1 and ColdFusion Builder 2 Updater 1 installed, you can set up ColdFusion Builder 2 to enhance your development.
The first task is to add ColdFusion to ColdFusion Builder 2 in the Server view. Click the Server tab and click the Add Server button.
Figure 31. Server Tab in ColdFusion Builder 2
Specify the following connection details for your server:
- Server Name: cfusion
- Host Name: localhost
- Select the Is local option
- WebServer Port: 80
- RDS Password: [As you specified during the installation process]
Figure 32. Adding a new server and specifying its Remote Development Server (RDS) settings
Next, enter your local settings. If you selected the default settings for your ColdFusion install, you can enter the Server Home as c:\JRun4. This will automatically specify the document root.
Figure 33. New server Local Server Settings
Click the URL Prefix table and type the following:
- Local Path: C:\Program Files\Apache Software Foundation\Apache2.2\htdocs
- URL Prefix: http://localhost
Click Add and Next.
Figure 34. New Server URL Prefix
You then have the option to install the extensions that come with ColdFusion Builder 2. To do so, leave the default options selected and click Finish.
Figure 35. Installing the extensions on a new server
Your server then appears in the Server panel.
Figure 36. Servers tab with new server
If you right-click your server, you can restart, stop, and edit the settng for the server. You're also able to access your ColdFusion Administrator.
Figure 37. Server menu options
When you open the ColdFusion Administrator, a panel displays in full screen. You can double-click the Tab to minimize it.
Figure 38. ColdFusion Administrator panel
When you click the Services Browser tab, you can see all the web services available on your ColdFusion.
Figure 39. Services Browser tab
In the Extensions tab you can see all the extensions you have installed and on which server. If you have multiple servers set up, you can see which server the extension will run from.
Figure 40. The Extension tab
Now that you have your server set up, you can create a ColdFusion Project in the navigator panel. Right-click the menu and select New > ColdFusion Project.
Figure 41. Creating a new ColdFusion Project
The new project window opens. Give the project a name, deselect the Use Default Location, and enter the Apache web root as C:\Program Files\Apache Software Foundation\Apache2.2\htdocs. Click Next.
Figure 42. Specifying the new project name and location
In the server details screen, select the server you have created and click Finish.
Figure 43. New project server details
Right-click your new project and select New > Folder.
Figure 44. Creating a folder in your project
Create a new folder called artistscfcs and click Finish. Repeat this step and create another folder called artistsorm.
Figure 45. Creating new folders in your project
In the main ColdFusion Builder 2 screen, select the RDS Dataview, which will show all the databases that are set up in your ColdFusion. Expand the
cfartgallerydata source, and then expand the data source's tables. Right-click the
Figure 46. The RDS data view of your data source
After right-clicking the table, you will see a list of options. You can view the contents of the table, which is a quick way to see the data of the table. You can also run the Query Viewer, which allows you to write queries. The lower section of the screen contains some of the extensions that were installed when you added the server to ColdFusion Builder 2. Select the Adobe CFC Generator > Create CFC option from the menu.
Figure 47. RDS data view menu options
You will be asked where the CFC should be stored. Click the Browse button and select the folder artistscfc folder that you created earlier. Click OK.
Figure 48. Folder selection
If you wish to see the fully-scripted cfc, select the Script CFC option. If you don't select this option, the Extension will generate standard ColdFusion code. Click OK.
Figure 49. The Adobe CFC Generator options
In the navigator panel you will see four new files:
- artists.cfc contains the main data for a artist row
- artistsdao.cfc contains all the CRUD functions for the
artiststable (Create, Read, Update, Delete single rows)
- artistsgateway.cfc performs all the database interactions for multiple rows
- artistsservice.cfc contains all functionality to interact with the
artiststable, giving you a great start in developing an OOP application
Figure 50. Generated files
In the RDS Dataview if you click the RDS Query Viewer you will be able to write very simple SQL statements.
Figure 51. The RDS Query Viewer
Now that you have connected everything, you can create a new file by right-clicking in the Navigator and selecting New > ColdFusion Page. Enter the name of your new file. This will create this file in your navigator. In this example, enter index.cfm as your file name.
In the new file, type the following:
<cfset artistsObj = createObject("component",</p>
By pressing CTRL + SPACE BAR, ColdFusion Builder will complete the code and you'll be able to select
artistscfc.ArtistsService,which will auto- complete the
Artistsservice in your code.
Figure 52. Component code insight
Placing a period after the closing parentheses will invoke the code insight on all the methods on the object, as this is the instantiation of the object selected in the init() function.
Figure 53. Code Insight in the function
Finish the code as follows:
<cfset artistsObj = createObject("component","artistscfcs.ARTISTSService").init() /> <cfset artistsQry = artistsObj.getAllARTISTS() /> <cfdump var="#artistsQry#"/>
You can click the IE tab at the bottom of the code editor to preview the page. By doing so, you can see an array dump of the objects that Adobe CFC Generator and your snippet of code generated.
Figure 54. Dumped array of Artists Beans object
If you require the Web Server to display your index.cfm file as the default page (no need to explicitly have index.cfm in the url) open the httpd.conf file located at:
C:/Program Files (x86)/Apache Software Foundation/Apache2.2/conf/httpd.conf.
Search for the line DirectoryIndex and enter index.cfm as the first item using a space separating them the section should look this:
# # DirectoryIndex: sets the file that Apache will serve if a directory # is requested. # <IfModule dir_module> DirectoryIndex index.cfm index.html </IfModule>
This will then serve index.cfm file as the default file of a folder. If a default file of index.cfm doesn't exist, the server will look for and serve index.html. Again if this doesn't exist the web server will either display a directory listing or a forbidden page depending on your Apache setup. The default behavior is to display a directory listing.
If you want the server to serve default.cfm as the default page, you can add default.cfm in the list with a space separator.
Once you have your environment installed, you can customize your install by adding more virtual servers, ColdFusion instances, and install ColdFusion Builder Extensions to help with your development.
For a good introduction to all the features of ColdFusion Builder, see the article, Moving from Dreamweaver to ColdFusion Builder. Although this article is for users moving from Dreamweaver to ColdFusion Builder, the article covers all the main features of ColdFusion Builder.