Instructions for local Apache installation

Downloading, unpacking and compiling

Make sure that you have enough disk space. On a Linux system you need (approximately):

Overview of the installation directories

Let us mention the directories and files important to us:

Configuring the port

Configuring CGI

Running Apache

The server is started, stopped and restarted using a program apachectl. Call this program with no arguments to see the options. Start the server with:
~/httpd/bin/apachectl start
Point your browser at "http://localhost:8080" and see if you can view the home page of your server.

Testing your CGI configuration

The ./httpd/cgi-bin directory contains a simple test script, but it is not enabled for security reasons. Do the following:
cd $HOME/cgi-bin
cp test-cgi test-cgi.cgi
chmod ugo+x test-cgi.cgi
Now, connect to "http://localhost:8080/cgi-bin/test-cgi.cgi?arg=foo" with your browser. You should see this:
CGI/1.0 test script report:

argc is 0. argv is .

SERVER_SOFTWARE = Apache/2.0.54 (Unix)
SERVER_NAME = localhost
HTTP_ACCEPT = text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
SCRIPT_NAME = /cgi-bin/test-cgi.cgi
QUERY_STRING = arg=foo
Now you are ready to run your own CGI scripts by putting them in $HOME/httpd/cgi-bin.

A note on DocumentRoot, ServerRoot and mapping browser requests to files

The configuration variable DocumentRoot is configured by this fragment of httpd.conf:
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
DocumentRoot "/home2/developer/httpd/htdocs"

The similarly named variable ServerRoot should not be confused with DocumentRoot. ServerRooot is the name of the UNIX directory where the configuration files reside. If you use the above configuration, ServerRoot is $HOME/httpd (where the directory "conf" with the file "httpd.conf" lives).

Document Root is the top directory in which the HTML files reside. This is a UNIX directory! In general, the term "directory" refers to the UNIX directory, while the term "location" is used to refer to a directory relative to the server root. Thus, if the browser requests "http://server_host/foo/bar.html", Apache configured as above, will serve the file /home2/developer/httpd/htdocs/foo/bar.html.

Marek Rychlik <>
Last modified: Fri Apr 22 21:38:21 MST 2005