Installing Apache 2.2.4 to a Windows-based computer, locally: Part 1

In February 2006, I wrote an article covering the installation of Apache 1.3.34, which can be found on my site, StrivingLife.net. In August 2006, I covered the installation of Apache 2.0.59. This time, I'll be covering the installation of the current version of Apache 2.2.x, Apache 2.2.4, to a Windows XP machine, for the purpose of local development.

While I'll be covering an installation of Apache 2.2.4 that will work along with Apache 1.3.x and Apache 2.0.x, this guide will work equally well if you're installing Apache 2.2.x by itself.

If you've been following along with my other tutorials on this local server setup, you may have setup Perl, PHP, MySQL, PostgreSQL, and/or ColdFusion, among other things. Later parts will cover these setups in further detail.

My environment

The computer I'll be using for this installation is an HP Pavilion a620n, 2.20 GHz, 960 MB (1 GB) of RAM, and with Windows XP Home, SP2.

Downloading Apache

The first thing, obviously, is to download the current version of Apache 2.2.x from http://www.apache.org/. At the time of this writing, Apache 2.2.4 is the current release, and "represents the best available version of Apache HTTP Server."

Since we're installing to Windows, we want to download the file apache_2.2.4-win32-x86-no_ssl.msi, which is under 4.5 MB in size. If you've been following along with the other tutorials, then you'll want to save this file to the same location as your other download files. If you haven't been following along, save the installation file to a directory where you can save all of your installation files.

While the file is downloading, if you're currently running a version of Apache on your machine, stop the server, as we don't want it running while we do the installation. If you have any other services running that may be running through port 80 (other Web servers), you'll also want to stop those services.

If you've already installed Apache 2.2.x, you may want to backup the install directory (the default is C:\Program Files\Apache Software Foundation\Apache2.2\).

Installing Apache 2.2.4

Once the installation file has been downloaded, run the file to begin installation. Continue throught the first window, to the second, where you can read and accept the license agreement. On the next window there's a bit of additional text to read.

Finally, you'll be asked for server information. Since we're installing this locally, we'll be using localhost as both the Network Domain, as well as the Server Name. In Administrator's Email Address, enter your real email address. Last, install Apache HTTP Server 2.2 programs and shortcuts for "All Users, on Port 80, as a Service".

You can now setup the server in a typical manner, or custom. Since we want to have control, select Custom.

On the first screen, you can select which features you want to install, and where they should be installed. We'll be installing everything, and leaving the installation directory as C:\Program Files\Apache Software Foundation\Apache2.2\.

And that's it. Press Install on the next screen to begin the installation.

Once the service has been created, you may recieve an alert from Windows Firewall regarding the Apache HTTP Server. Choose to Unblock this program.

In addition, if you've already installed Apache, and have the Apache monitor running, you'll receive an error that the monitor is already running.

Once the installation has finished, press the Finish button.

Apache HTTP Server 2.2.4 will now be running, and by going to http://localhost/, you'll see the text "It works!" in your browser.

If you do not see this, or the service does not start, you can find an error.log file in the logs directory in your Apache install directory which can help you troubleshoot your issue.

Apache Service Monitor, and setting startup types

In your taskbar, there will now be an icon from the Apache Service Monitor. Using the monitor, you can easily start and stop the Apache HTTP Server, as well as access other services.

For now, hit the Services button to bring up the Services console. Next, right click on the Apache2 service, and select Properties. What we're going to do now is change the startup type from Automatic to Manual. This means that we'll need to manually start Apache whenever we restart our computer, but it also means that the service isn't unnecessarily running.

However, if you'll be running Apache every time you login, you may want to let Apache startup automatically when you log in. Either way, it's nice to know where you can change this.

While you're here, note that you can also see what version of Apache is running, in the Description field.

Wait a second, what about the Apache 2.0.59 service?!?

If you've installed Apache 2.0.59 previously, you may be wondering what happened to the Apache2 service for that version of Apache.

Unfortunately, Apache 2.0.59 and Apache 2.2.4 use the same service name. This means that any previous Apache2 services will be overwritten.

Luckily, with the help of Windows, Microsoft, and some advice from Mark Lennox (given in a Subversion article), we can create a service for Apache 2.0.59 a couple of ways.

First, run cmd via the Run command (Window + R, or via the Start menu). At the prompt, enter the following. Please note that you'll want to confirm that the path information is correct for you.

sc create Apache2.0 binpath= "\"C:\Program Files\Apache Group\Apache2\bin\Apache.exe\" -k runservice" displayname= "Apache 2.0" depend= Tcpip/Afd

You can learn more creating Windows services using the SC tool (Sc.exe) by reading support article 251192 on Microsoft.com.

You may also want to create new services for Apache 2.2.x, and Apache 1.3.x. However, keep in mind that once you change your configuration, you may need to remove/update the services that you create. Either way, the new services should display in the Apache Services Monitor.

sc create Apache1.3 binpath= "\"C:\Program Files\Apache Group\Apache\Apache.exe\" --ntservice" displayname= "Apache 1.3" depend= Tcpip/Afd

(Note that there's two dashes in front of ntservice.)

sc create Apache2.2 binpath= "\"C:\Program Files\Apache Software Foundation\Apache2.2\bin\httpd.exe\" -k runservice" displayname= "Apache 2.2" depend= Tcpip/Afd

If you've been following along with my other tutorials, you may want to update your batch files so that they stop all the Apache services (Apache, Apache2, Apache1.3, Apache2.0, Apache2.2) and start our new services, depending upon which version you want to run (currently, that would be either Apache1.3 or Apache2.0).

Configuring Apache with httpd.conf

If we start Apache 2.2 back up, via services, and browse to http://localhost/ once again, we'll see that "It works!" screen. That's all well and good, but it's using C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\ as the Web directory, from which is serves content, which is far too deep to dig.

It's better to create another folder, with less pathing information. I've decided to use the shorter directory of C:\home\, however, you can create whatever folder you'd like. In this directory, you'll store any files that you'll want to be served by Apache. There's exceptions to this statement, but, for now, we'll let it slide.

Once you've created this directory, head over to the conf folder in the install directory of Apache 2.2.x (default of C:\Program Files\Apache Software Foundation\Apache2.2\conf\) and make a copy of the httpd.conf file. This copy will serve as the original, just in case something happens. This is a working version of the configuration file for Apache HTTP Server, so don't overwrite it (but if you do, there's a copy in the default folder). Now open the httpd.conf file.

With the httpd.conf file open, do a search for DocumentRoot. The second instance will take you to a line that reads as follows.

DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"

Change the quoted text to your Web root folder (make note of the direction of the slashes, and absence of a slash at the end). Since I created a folder at C:\home, I'll be using the following line.

DocumentRoot "C:/home"

Find the next instance of DocumentRoot and you'll see this line of text two lines down.

<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs">

Change the directory as you did just moments ago.

<Directory "C:/home">

Note that in this file you can also change what port Apache 2.2.x will listen on. There's two instances of the port number, and a search for 80 will turn up both, if you choose the options we did above. Otherwise, you'll turn up four instances (as Apache will be listening on Port 8080).

Save the httpd.conf file and restart, or start, Apache.

If you go to http://localhost/ now, you'll either see a directory listing, or a Web page, depending upon whether you have an index.html file in your Web root. If this worked, then you can make a backup copy of your newly working httpd.conf file.

And with that, you've setup Apache 2.2.4 on a local Web server.

In later guides, we'll cover the setting up of a number of additional services, but for now, you can work static Web pages.

If you've followed some of my other tutorials, you can easily switch between versions of Apache, but you'll need to configure any batch files you may use so that they stop the new Apache 2.2.x service.

Questions or comments can be left below, or emailed to me directly (email at the bottom of the page). Thanks for reading!