How to Install and Configure Apache on Windows

Steps to Installing and Configuring Apache 2 for Windows XP


Download Apache 2

Firstly, download a copy of Apache 2. scroll down the page to the appropriate section.
Win32 Binary without crypto (no mod_ssl) (MSI Installer): httpd-2.2.17-win32-x86-no_ssl.msi
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.  

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. 

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.

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 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. 

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. 

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

No comments: