How to Install and Configure Apache 2 on Windows

Setup and configure a local server to test your PHP and Perl scripts

How to Install and Configure Apache 2 on Windows

by Christopher Heng,

Many webmasters choose to install a copy of the Apache web server on their machines so that they can test their PHP and Perl scripts before they upload it to their "live" websites. This allows them to fix any problems on their site before it actually affects their website's visitors. This article deals with how you can set up and configure Apache 2 on your own computer so that you can test your scripts and site.

Preliminary Notes

Steps to Installing and Configuring Apache 2 for Windows XP

  1. Download Apache 2

    Firstly, download a copy of Apache 2. Since we are talking about Apache 2 here, be sure to scroll down the page to the appropriate section. Select the "Other files" link in that section to get a complete listing of the available Apache 2 versions. In the new page that appears, click the "binaries" folder followed by the "win32" folder. A list of files with different version numbers will be listed.

    If you want the Apache 2.0 series, and the current version of the Apache 2.0 series is, say, 2.0.61, look for the file named "apache-2.0.61-win32-x86-no_ssl.msi". Likewise if you want the Apache 2.2 series, and the current version is, say, 2.2.6, go for the file named "apache-2.2.6-win32-x86-no_ssl.msi".

    Click it and save the file to your hard disk. Remember where you saved it so that you can run it later.

  2. Run the Apache Installer

    When you have finished downloading the file, double-click it to run the Apache installer. Follow the instructions to install Apache.

    When you arrive at the "Server Information" dialog box, enter "localhost" (without the quotes) for the Network Domain as well as for the Server Name and whatever email address you wish for the "Administrator's Email Address" field. The installer uses the information you enter to create a default Apache configuration file for you. You can always go back and manually change these values in your configuration file if you change your mind later. Leave the default setting of "for All Users, on Port 80, as a Service" as it is. Click "Next" when you're done.

    When asked about the Setup Type, select "Typical" and click "Next".

    Allow the installer to install to the default folder in the next screen. Note that this tutorial will assume that you are using the default folder of "c:\Program Files\Apache Group\" here. Click "Next".

    Finally click the "Install" button to allow the installer to set up Apache. When it is done, click the "Finish" button.

  3. Enabling and Disabling the Apache Service

    The Apache installer automatically starts the Apache service when it finishes the installation. If you ever wish to stop the Apache 2 service and only start it manually when you need to use it for testing, go to Control Panel -> Administrative Tools -> Services, look for the "Apache2" service and double-click it. From here you can stop the service and change the startup type to "Manual". The Apache service will then terminate and only start when you return to this control panel applet to manually start it. This is useful if, like me, you're only using the server to test your scripts, and don't want the server running all the time.

  4. Changing the Server Name and Administrator's Email Address

    If you want to change the server name that you entered when you set up Apache, use the Start menu to open the Apache configuration file: you can find the appropriate item at Start -> Programs -> Apache HTTP Server -> Configure Apache Server -> Edit the Apache httpd.conf Configuration File.

    A Notepad window will open with your Apache configuration file loaded. If you ever need to load your configuration file with another ASCII editor, it can be found at "C:\Program Files\Apache Group\Apache2\conf\httpd.conf" for Apache 2.0 and "C:/Program Files/Apache Software Foundation/Apache2.2" for Apache 2.2.

    Search for the following text and replace the "localhost" with the name you want.

    ServerName localhost:80

    Likewise if you want to change the Administrator's Email Address that you entered earlier, look for a line like the following:

    ServerAdmin admin@localdomain

    The exact email address displayed will be different, depending on what you entered during the setup process earlier.

    In general, if you are just setting up Apache for private offline testing, you can basically leave these settings as they are.

  5. Configuring Apache to Accept Server Side Includes (SSI)

    If you want the web server to parse Server Side Includes (SSI directives), search for the text "server-side includes" in the file. Add the following lines just after the block of text containing those words:

    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml

    Alternatively, you can uncomment the example text given in the configuration file by removing the hash prefix ("#") before each line.

    Apache will now handle the SSI directives that occur in files with names ending in ".shtml".

    If you want "index.shtml" to be your default start page for your directories, ie, if you want Apache to load "index.shtml" when you type "localhost" or "localhost/directory/", you will need to search for a line in your "httpd.conf" that begins with "DirectoryIndex" and add index.shtml to the list of files there. For example, modify it as follows:

    DirectoryIndex index.shtml index.html

    Adding it before index.html means that Apache will give preference to index.shtml if both are present.

  6. Save the Configuration File and Restart Apache

    When you are satisfied with your changes, save the file - just use the "Save" item from the "File" menu or type Ctrl+S. After you make a configuration change, you need to restart Apache. To do this, go to the Start Menu and click the "Restart" item in the "Control Apache" folder, that is, select Start -> Programs -> Apache HTTP Server -> Control Apache Server -> Restart.

How to Test Your Apache Server

To test if your server is installed and configured properly, open up a browser and type "localhost" in the location bar of your browser. You should be able to see the default Apache test page.

Where to Place Your Website

By default, your pages should be placed in the "C:\Program Files\Apache Group\Apache2\htdocs" folder for Apache 2.0 and the "C:\Program Files\Apache Software Foundation\Apache2.2\htdocs" folder for Apache 2.2. When your site is ready, simply delete the existing files in the folder and replace them with those you want to test.

The Next Step

The next thing to do is to learn how you can install PHP to work with your Apache web server. You can find the tutorial for this at

This article can be found at

Copyright © 2007-2018 by Christopher Heng. All rights reserved.
Get more free tips and articles like this, on web design, promotion, revenue and scripting, from

thesitewizard™ News Feed (RSS Site Feed)  Subscribe to newsfeed

Do you find this article useful? You can learn of new articles and scripts that are published on by subscribing to the RSS feed. Simply point your RSS feed reader or a browser that supports RSS feeds at You can read more about how to subscribe to RSS site feeds from my RSS FAQ.

Please Do Not Reprint This Article

This article is copyrighted. Please do not reproduce or distribute this article in whole or part, in any form.

Related Articles

New Articles

Popular Articles

How to Link to This Page

It will appear on your page as:

How to Install and Configure Apache 2 on Windows

Link to Us
No Spam Policy
Privacy Policy
Site Map

Getting Started
Web Design
Search Engines
Revenue Making
Web Hosting
Perl / CGI
.htaccess / Apache


Free webmasters and programmers resources, scripts and tutorials Free How-To Guides
Site Design Tips at
Find this site useful?
Please link to us.