Home arrow Apache arrow Page 3 - Configuring and Using the Apache HTTP Web Server on a Windows XP PC

Opening the File and Making Modifications - Apache

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.

  1. Configuring and Using the Apache HTTP Web Server on a Windows XP PC
  2. Get the Software and Set up a Directory Structure
  3. Opening the File and Making Modifications
  4. Testing
By: Dan Wellman
Rating: starstarstarstarstar / 122
May 24, 2004

print this article



If, when you attempt to open the file for the first time, you receive an error message advising that you do not have an associated program with which to open this type of file (as I did), you will need to choose Notepad from the list of selected programs.  If this fails to work; browse to the location of the file - as stated above – then open a blank Notepad window and just drag the file in.

The file itself is broken up into three distinct sections: the global environment, the ‘main’ server configuration, and the virtual hosts section.  The first section enables you to change settings that affect the overall operation of the server, and for our purposes here, can pretty much be left unchanged (although do read through some of the comments to give yourself a better overview of how the program works.) 

The second section is where we will make most, if not all, of our modifications.  This is the section which deals with which folders the server looks in when pages or files are requested by the browser, and the settings and preferences regarding what is allowed to be executed from these folders.

The third section is used entirely to specify any virtual hosts that you want the server to manage.  If you want to run several sites/domains from one server, this is the section that you need to modify.  Again, for the purpose of this article, you can safely ignore this section.

So, with the httpd file open, scroll right down through the first section, and right near the top of the second section (line 210), you’ll see ServerName.  If this doesn’t say localhost:80, change it so that it does.  Next, change the DocumentRoot statement (which is the second actual statement following ServerName) to read as follows:

DocumentRoot "C:Documents and SettingsYourusernamehereMy DocumentsMyWebsitelocalhostwww" 

Now scroll down to the second instance of the <Directory > option.  This, as stated in the block of comments above it, should be changed to whatever you set DocumentRoot to; in this case:

<Directory "C:Documents and SettingsYourusernamehereMy DocumentsMy Websitelocalhostwww">

Directly below the comments that follow the above statement, you’ll see a statement that begins with Options.  Make sure that this line contains the words Includes and ExecCGI, so that it looks like this:

Options Multiviews Indexes SymLinksifownerMatch Includes ExecCGI

This will enable SSI and executable CGI scripts in your DocumentRoot.  If there is a # symbol at the start of this line, ensure that you remove it.

Scroll down a bit more and you’ll see the UserDir statement, make sure it says:

UserDir "My Documents/My Website"

Almost directly below this, there is another <Directory > option.  You will need to remove all of the # symbols from the opening <Directory > to the closing </Directory > Tag and this will need to be set to:

<Directory "C:/Documents and Settings/Yourusernamehere/My Documents/My Website/localhost">

Again, I’ve found it best to add Includes and ExecCGI in the options statement below this.

Below this closing <Directory > tag, there is the DirectoryIndex statement; simply append index.htm and index.cgi to the end of this line. 

You’ll need to scroll down quite a way now, until you come across the line that begins with ScriptAlias /cgi-bin/.  Change this line to read:

ScriptAlias /cgi-bin/ "C:/Documents and Settings/Yourusernamehere/My Documents/My Website/localhost/cgi" 

There may be a comment symbol (#) at the start of the ScriptAlias statement, if so, remove it.  Four lines below this amend the <Directory > tag to:

<Directory "C:Documents and SettingsYourusernamehereMy DocumentsMy Websitelocalhostcgi">

Now scroll down for some time until you see the AddType application lines.  In order to use PHP, you’ll need to add the following directive:

AddType application/x-httpd-php php

Insert the above line directly below the AddType directives already present, and then add the following statements directly below that:

ScriptAlias /_php/ "C:/Program Files/PHP/"

Action application/x-httpd-php "/_php/php.exe"

The ScriptAlias needs to match the directory you’ve installed PHP in, so amend it accordingly.

Now a little further down you’ll find the AddHandler directive.  All you need to do here is add .bat and .pl to the end of this line. Also add AddHandler server-parsed .html to the very next line.

Keep going down, and very soon you will see AddType text/html .shtml, which can be left as-is, but may need to delete the # from the start of the line, and will need:

AddHandler server-parsed .shtml .html .htm

added to the next line.  You’ll be relieved to hear that that is the end of configuring the conf file.  Save the document and then restart the Apache Server.

>>> More Apache Articles          >>> More By Dan Wellman

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Apache Unveils Cassandra 1.2
- Apache on ARM Chips? Dell and Calxeda Help M...
- The Down Side of Open Source Software
- VMware Unveils Serengeti for Apache Hadoop
- SAP Takes Steps to Improve Hadoop Integration
- Looking to Hone Apache Hadoop Skills?
- How to Install Joomla on WAMPP
- Working with XAMPP and Wordpress
- GUI Available for Apache Camel
- Reduce Server Load for Apache and PHP Websit...
- Creating a VAMP (Vista, Apache, MySQL, PHP) ...
- Putting Apache in Jail
- Containing Intrusions in Apache
- Server Limits for Apache Security
- Setting Permissions in Apache

Developer Shed Affiliates


Dev Shed Tutorial Topics: