HomeApache Configuring and Using the Apache HTTP Web Server on a Windows XP PC
Configuring and Using the Apache HTTP Web Server on a Windows XP PC
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.
It is a piece of software that can basically create a virtual web server on your PC. The program is open source, which means that as a developer, you can download the source files and experiment with changes to the code in the hope of modifying the program for the better. It also means that the program has a General Public License, which to you and me, means for free! The great thing about this (and most other open source software available these days), is that you don’t have to download the source code and try to install it from that. All of us non-software developers out there can download a nicely packaged MSI or WIP file. MSI, by the way, stands for MicroSoft Installation, and WIP for Windows Installer Package. So we get a powerful program, for free, that we can install with minimum effort. You can of course give a financial donation to the HTTP project, which, when you’re making software for nothing, you kind of rely on in order to keep going. Feel free to, at your own discretion.
So what’s the point in having it?
When you connect to the Internet and type, for example www.hotmail.com, you’re telling your browser to locate the hotmail sub-domain on the .com top level domain. Testing HTML pages you’ve written yourself and haven’t uploaded is a pretty standard operation; you open Internet Explorer (or whichever browser you happen to be using) and open the page; simple. Most HTML editors have a ‘preview in browser’ button just for this. But how do you test PHP code? Or that little CGI script that you’ve written? The answer lies within Apache. It acts as a local server; you put any pages or scripts that you want to test in a specified directory, and in the address bar, type something like http://localhost/pagethatyouwanttotest.htm
Your browser then requests the page from the server called localhost, or whatever you’ve configured it to, in the same way that it would if you were connected to the Internet. Any script files referenced in the page are executed on the server and the results passed to the browser. This is an excellent resource for anyone developing web applications in PHP, Perl or ASP, and lets you see pretty much exactly what any visitors to your site will see once it’s live. You can also use the Apache HTTP Web Server to host your website on the Internet, as many people have chosen to do, but we won’t go into that here because it’s way past the scope of this article. We’ll concentrate solely on using it on your desktop PC purely for testing code.