Okay gang, it's official. Apache rocks, and you want it to power your Web sites. No ifs, ands, or buts. You want it. Of course most people using Apache are using it on a *NIX-type environment where it was more than likely installed by default. Red Hat Linux? Installed by default. Mandrake Linux? Installed by default. Even if your *NIX environment didn't include the Apache server, it's simply a matter of downloading the source, compiling the source, and restarting the httpd daemon.
But what about Windows? Is the installation as simple as in the *NIX environment? Well, yes and no. There are a few hoops to jump through, and that's what this article will help you with. So stoke up the campfire and get ready to install the baddest Web server on the prairie!
Getting the application
Point your browser to one of the official Apache mirror sites, such as this one, to download the correct .exe file. (I point you to this mirror site because finding the actual Win32 executable file can be a bit harrowing. When you go to the official Apache site, the download section is dedicated to the *NIX platforms.)
Installing the Apache server
I hesitate to even dedicate space to this topic because the installation is really just a matter of double-clicking the executable file. The installation will then create the following directories under C:\Program Files:
- Apache Group
Within the Apache directory, you will find a number of subdirectories and files. The files within this directory are not critical to your understanding of the Web server application. Many of these files are keys, license information, install logs, makefile information, an executable, and a .dll file. These can be pretty much ignored.
There are, however, a few subdirectories that you will want to familiarize yourself with. The first of these subdirectories is htdocs. This directory is where you will house your pages and pages of HTML. Change to that directory and you will see the pieces that make up the Apache test page (the page your browser points to when you first run http://localhost).
One other subdirectory you will want to know is conf. This directory contains all the configuration files you will need to use for your Apache Web server.
Before you actually use your new Web server, you will have to make one initial configuration change and you will want to make another. You will make these changes in the Apache Group/Apache/conf/httpd.conf file. The configuration you must change is shown in bold:
# ServerName allows you to set a host name which is sent back to
# clients for your server if it's different than the one the
# program would get (i.e., use "www" instead of the host's real
# Note: You cannot just invent host names and hope they work. The
# name you define here must be a valid DNS name for your host. If
# you don't understand this, ask your network administrator.
# If your host doesn't have a registered DNS name, enter its IP
# address here.
# You will have to access it by its address (e.g.,
# anyway, and this will make redirections work in a sensible way.
As you can see, I have entered my server's IP address in the ServerName entry. The default configuration is something like:
Without this entry configured, you will only find yourself coming up with everyone's favorite error—404.
The configuration you will want to change is the administrator’s e-mail address. The change is shown in bold here:
# ServerAdmin: Your address, where problems with the server should
# be e-mailed. This address appears on some server-generated
# pages, such as error documents.
As you can see, I have entered my own TechRepublic e-mail address as the administrator’s address.
Starting the server
Once you have your server properly configured, you must then start the server. There are two ways to do this. The first, and most Windows-like, is to click on the Start Apache menu entry by navigating through Start | Programs | Apache Web Server | Start Apache. When you do, a command prompt will open telling you that the Apache server is running. You can then point your browser to http://localhost/, and the Apache test page will fire up.
The next method is to open a command prompt, change to the Apache Group/Apache directory, and run any of the following commands:
- apache -k start
Any of these three commands will start the Apache server.
When you start the Apache server, the command prompt window will remain open. If you cancel that command (with [Ctrl]Z) or kill the window, the Apache server will die.
So you now have Apache installed on Windows. Feel better? You should. Although Apache has not been optimized (yet) for the Windows platform, it is still a very reliable Web server that you can easily set up, start up, and quickly forget.
Of course if you want more in-depth information on configuring Apache, you can saddle up and mosey over to the official Apache site for a campfire full of documents!
The authors and editors have taken care in preparation of the content contained herein but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for any damages. Always have a verified backup before making any changes.
Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.