Web Server Administration : Apache Configuration Lab

Apache Configuration Lab

Installing Apache is the easy part, now lets take a look at how to modify some of the configuration directives.

The ~/apache/conf directory contains the configuration files for Apache. These files are all plain ASCII text files and can be viewed or edited with pico. The main configuration file is httpd.conf. This file should contain the configuration directives that control how the Apache httpd behaves. Lines that begin with a # are comments.

To modify the configuration simply add or modify lines to the httpd.conf file, save it, and restart apache. (The apachectl restart command can be used to restart)

Documentation for Apache is located at: http://www.apache.org/docs/

The directives are all listed under the "Run-time configuration directives"

1) The ServerRoot directive specifies the directory that Apache was installed into. In our case it should be /export/home/ericl/apache/. Under this directory are several other directories. We already saw the "conf" directory. There is also an "htdocs" directory which is known as the document root directory. This directory contains the default web pages you saw when you connected to the server with Netscape.

Let's change the document root directory by changing the DocumentRoot directive to "c:/docs"

Restart Apache and reload http://localhost in your browser (you might have to do a shift-reload). What happens?

Now create the c:/docs directory on your hard drive. Reload. What happens?

2) Just for kicks, let's make the DocumentRoot /
Restart, reload, what do you see? Why is this a bad idea?

3) Let's configure the server to not show us complete directory listings…
Some directives actually form blocks.
Find the line that looks like this in the conf file:
<Directory "/export/home/ericl/apache/htdocs">
This directive actually has an ending "tag" (similar to HTML) that looks like this:
</Directory>
Everything between these tags only applys to the /export/home/ericl/apache/htdocs directory. Change it to apply to /
Now remove the Indexes from the Options directive.
Restart, reload, what happens?