HomeApache Page 2 - Configuring and Using the Apache HTTP Web Server on a Windows XP PC
Get the Software and Set up a Directory Structure - Apache
Author Dan Wellman explains what the Apache HTTP web server is and how it acts as a local server so you can test PHP code or CGI scripts you've written to see how they will look live. Wellman concentrates on using it on your desktop PC purely for testing code.
Answer the prompts in your usual manner. The installation file is 5.81Mb, so go and make a cup of tea or something, and when you come back, it should be done. To install the server; run the executable youíve just downloaded and accept the terms. Enter localhost in the domain and servername text fields, and just enter yourname@localhost in the bottom one. Leave the target directory and hit install. Once the program has installed successfully, youíll see an Apache icon with a green play symbol on it in your system tray (right there, next to the clock). This means the server is running. To stop or restart the server (to pick up changes made in the configuration file for example), just left-click this icon and select Apache2 / Stop or Restart. When the server has stopped, the same icon, but with a red stop symbol on it will be in your system tray. You may at this point also wish to install PHP. If so, go to www.php.net and download the exe file and the zip file. Run the exe file; you can leave most of the defaults as they are, but change the target directory from C:php to C:program filesphp.
And itís as easy as that? Not quite; you could of course, leave the Apache configuration file exactly as it is and host all of your test pages and scripts out of the default folder, which happens to be C:Program FilesApache GroupApache2htdocs. Lovely.
Ideally though, you want to set up a directory structure that is easy to remember the file path of, and at least vaguely reflects the directory structure that is used on web servers. Additionally, you need to at least make some minor changes to the configuration file in order to enable SSI includes and CGI, which of course, you want to do (donít you?)
But first a little groundwork; in the My Documents folder, create a folder called My Website, and within that, create a folder called localhost. Now create two folders in the localhost folder; one called www and one called cgi. Thatís your directory structure set up. Now, what happens if you make some changes in the configuration file only to find that the server doesnít function correctly? Or worse still, the server won't even start? Fortunately, this release of Apache has a backup configuration file called httpd.default (youíll notice that all of the files in the conf folder are backed up in this way.) So if you want to return to the original configuration file, just copy and paste the entire contents of the .default file into the httpd file, which is the main configuration file. This is a lot quicker, easier and less frustrating in general than uninstalling and then reinstalling the program repeatedly, until you get it right. Both of these files are kept in the C:Program FilesApache GroupApache2conf folder, but another great thing about Apache is that you donít have to browse through your filing system to find the main configuration file, you just launch it using the ĎEdit the Apache httpd.conf Configuration fileí shortcut, which can be found under:
Start / Apache HTTP Server 2.0.49 / Configure Apache Server.