|[ LiB ]|
To develop offline, using your own computer as the development web server, you need to make sure that the HTTP server, application server, database software, and any necessary drivers are installed and correctly configured.
Your main choices for the HTTP server are IIS and Apache. If you're setting up for ColdFusion development, you can also run the ColdFusion server as a stand-alone server (performing HTTP server and application server duties ), so you'll install that instead of Apache or IIS. You should still read the upcoming section "Serving Pages Locally," however, to understand how local HTTP servers work.
If you're running Windows NT, 2000, or XP Pro, the simplest HTTP server to install for development is IIS. For NT users, the IIS software is part of the Windows NT 4.0 Option Pack, which you can download from the Microsoft website. For other users, the IIS software is on your Windows Install CD.
IIS installs as a service, meaning that it starts automatically when the computer boots. To access and configure IIS, select Start > Control Panel > (Administrative Tools) > Internet Services Manager.
To get help using IIS, launch your browser and type http://localhost/iishelp in the URL field.
IIS is the most common choice as a Windows server, but it isn't the only choice. Especially if you're working with PHP, before uploading to a Unix server, you might want to more closely duplicate your eventual online environment by using Apache as your HTTP server. Apache is free and easily available.
If you have IIS on your computer, it's best not to run IIS and Apache at the same time.
Windows users can download Apache from the Apache Group (http://httpd.apache.org/). Apache is always developing, but it's usually available as a self-installing EXE file with complete instructions for configuration. You can choose to install it as a service (which starts up every time your computer starts up) or as an application, which you can start and stop from the desktop.
For Mac users, the Apache HTTP server comes preinstalled with OS X. All you have to do to turn it on is launch System Preferences, go to the Sharing pane, and enable Web Sharing. With Web Sharing enabled, Apache automatically starts and runs in the background every time you start your computer.
To browse locally served pages, your browser must pass an HTTP request to the server software by specifying the HTTP protocol followed by your computer's IP address or computer name , or the generic IP address ( 127.0.0.1 ) or name ( localhost ) that computers use to refer to themselves .
Entering any of the following into the address field of the browser acts as a request telling the server to display (or serve ) its default page:
http://localhost http://127.0.0.1/ http://184.108.40.206/ (substitute your computer's IP address)
Figures 21.7 and 21.8 show this happening.
Each server has a root directory, or folder, from which it serves its pages. You can request any web document placed in the root directory, or in a subfolder within the root directory. For instance, you can request a file called myfile.html , stored in a folder called myFiles , which is stored inside the server's root directory, by entering the following into the browser's address field:
http://220.127.116.11/myFiles/index.html (substitute your IP address)
For IIS, the root folder from which all pages are served is c:\Inetpub\ wwwroot .
For Apache/Windows, the root folder is the htdocs folder in your Apache program folder. The exact path to this folder varies, depending on your installation.
For Apache/Mac, the root folder is /Library/WebServer/Documents .
(If you'll be using ColdFusion as your HTTP server, see the later section "Using ColdFusion as Your HTTP Server" for specific instructions on browsing served ColdFusion pages.)
The quickest way to test whether you have correctly identified your root folder is to create a simple HTML file called mytest.html or some other generic name and store it in what you think is the root folder. Then open your browser and type http://localhost/mytest.html . Your page should appear.
You also need to make sure that the correct application server software is installed and correctly configured on your computer. The application servers covered in this book are ASP.NET, PHP, and ColdFusion.
To develop and test PHP pages locally, you need the PHP server module or CGI application. Windows users can download it from the PHP website (http://www.php.net/downloads.php). Make sure you download a Windows binary version and not source code. This is a self-installing version with complete documentation.
For Mac users, the Apache server in OS X includes a disabled PHP module. You enable it by typing a few lines of code in the Terminal window. For full instructions, visit the Apple website at http://developer.apple.com/internet/macosx/php.html.
To develop and test ColdFusion pages locally, you must install the ColdFusion Server software. This is a commercial program, but a free developer's edition is available for users who want to develop and test on one computer. For Windows users, ColdFusion Server development edition is included on the Macromedia Studio MX 2004 CD, or you can download it from the Macromedia website (http://www.macromedia.com/software/coldfusion/). For Mac users, currently the only option available is to download the ColdFusion Java edition, also available on the Macromedia website. Be aware, though, that this is a Java installation, and installing it is not for novices.
During installation, you'll be asked to provide an administrative password to access the server for setup purposes. Be sure to remember or jot down what you enter here! You'll need it later.
ColdFusion can run as a stand-alone server, which means it functions as HTTP server and application server. By default, it operates through port 8500, which means it can run at the same time as IIS or Apache without getting in their way. It also means that you must access all served pages using the following URL formula:
The root folder from which ColdFusion Server serves its documents is CFusionMX\wwwroot\. With the default Windows installation, you'll find this on your C drive. Any files or folders placed within this folder can be accessed using these URLs.
The ColdFusion Server administrative interface, shown in Figure 21.9, is a set of web pages that you can access through your browser at http://localhost:8500/CFIDE/administrator/ . You need to enter your administrative password to gain access to these pages.
ASP itself is part of IIS, so it needs no installation. To develop and test ASP.NET locally, you must download and install the .NET framework from Microsoft (http://www.microsoft.com/net). Extensive installation and configuration help is available through the website and documentation. Be warned that this is a big download!
You can't serve pages built from databases unless you have the proper database management software (DBMS) on your computer. The most popular choices for small business and individual websites are Access and MySQL.
For Windows users, Microsoft Access is easy to obtain. You might already have it on your computer. For local development, your database file can be stored anywhere on your computer.
MySQL is freely available for both Mac and Windows. It's fairly easy to use, but not that easy to set up. For full information on MySQL, visit the official website at http://www.mysql.com.
Windows users can download a self-installing EXE for MySQL from the MySQL website. (Be sure to download the Windows binary.) After it's installed, start the server portion of the program by launching WinMySQLAdmin. This program runs in the background and appears as a traffic light icon in the taskbar. You'll also probably want to obtain a GUI. MySQL Control Center, available from the MySQL website, is free and easy to use.
Mac users can also download a MySQL version from the official website, but you'll have a much easier time if you download a graphic installer such as the one from Marc Liyanage (http://www.entropy.ch). Full installation and configuration instructions are included. You'll also want a GUI, like the free CocoaMySQL, available from Source Forge (http://cocoamysql. sourceforge .net/).
Database files must be stored where the MySQL server can find them. Each database consists of several files stored in a folder named after the database, in the mysql/data folder. The exact location of this folder on your hard drive depends on which MySQL installation you use. Figure 21.10 shows the MySQL folder structure and database files.
Each database you'll communicate with requires some sort of driver to connect to. The driver setup you need depends on which server technology you're using.
To work with ColdFusion, databases must be registered with the ColdFusion server. To do this, launch the ColdFusion administrator pages (see the earlier section "Setting Up ColdFusion" for more on this). From the main page, choose Data & Services > Data Sources to access the controls.
If you're using Windows and you're connecting to an Access database, ColdFusion Server automatically creates a DSN for you. Read the section "ASP.NET and DSNs" for more on DSNs.
In the Add New Data Source section, give your data source a one-word name, and select the driver type (Access, MySQL, and so on). Then click the Add button. In the Data Source page that appears, fill in the required information (this varies, depending on the driver type you have chosen ) and click Submit. If all is well, after a few moments the screen changes, and your database is listed in the Connected Data Sources section.
When used with MySQL (as it is in Dreamweaver), PHP requires no drivers. Instead, it communicates with the MySQL server application and can access any database on the system.
ASP.NET requires a Data Source Name (DSN) to communicate with databases. DSNs are ODBC drivers and are created and managed through the Data Sources (ODBC) control panel. To create a DSN, open the control panel, bring the System DSN tab to the front, and click the Add button. When the new DSN window appears, choose the appropriate driver from the list of drivers (depending on what kind of database you're using), and enter whatever additional information is required. For Access databases, it's as simple as browsing to select the database. When you're done, close all dialog boxes. You now have a method of accessing this database file from any web application on your computer. Figure 21.11 shows the interface for defining DSNs.
ASP.NET can also use a DSN-less connection string to establish communication with the database, in which case a DSN is unnecessary. This requires more skill to code, and you don't need to do it before you set up Dreamweaver.
|[ LiB ]|