Basic Apache Configuration

Apache

Apache is an open source HTTP server that drives over half of the Web sites. It is highly configurable and extensible, and of course you can get the source code. It runs on a huge number of oeprating systems, so allows a clear upgrade path if your current hardware proves inadequate.

Apache configuration

Apache is controlled from a configuration file. Under our system it can be run by


/usr/sbin/httpd -f config-file
The default configuration file is in /etc/httpd/conf/httpd.conf.

The contents of this file include (much is omitted!)


# ServerType is either inetd, or standalone.

ServerType standalone

# Port: The port the standalone listens to. For ports < 1023, you will
# need httpd to be run as root initially.

Port 80

# ServerAdmin: Your address, where problems with the server should be
# e-mailed.

ServerAdmin root@localhost

# ServerRoot: The directory the server's config, error, and log files
# are kept in.

ServerRoot /etc/httpd

# ErrorLog: The location of the error log file. If this does not start
# with /, ServerRoot is prepended to it.

ErrorLog logs/error_log

# The location of the access logfile (Common Logfile Format).
# If this does not start with /, ServerRoot is prepended to it.

CustomLog logs/access_log common

# PidFile: The file the server should log its pid to
PidFile /var/run/httpd.pid

You will need to change these to run the server as other than root. Recommended: set ServerRoot to one of your subdirectories. Do not set it to a high-level directory such as '/' - that opens up the entire file system to HTTP access from external sites and is a bad thing. e.g.


    Port 8001
    ServerAdmin your-id@localhost
    ServerRoot /your-home-dir/httpd
    PidFile /your-home-dir/httpd/httpd.pid
Place the configuration file in ServerRoot/conf/httpd.conf.

That gets the server going. It then needs to know where the HTML files are delivered from, and where the CGI scripts live. This is controlled by srm.conf, which should be placed in the ServerRoot/conf/ directory. Relevant entries include


# 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 /home/httpd/html

# DirectoryIndex: Name of the file or files to use as a pre-written HTML
# directory index.  Separate multiple entries with spaces.

DirectoryIndex index.html index.shtml index.cgi

# ScriptAlias: This controls which directories contain server scripts.
# Format: ScriptAlias fakename realname

ScriptAlias /cgi-bin/ /home/httpd/cgi-bin/

# If you want to use server side includes, or CGI outside
# ScriptAliased directories, uncomment the following lines.

# To use server-parsed HTML files (Server-side includes)
AddType text/html .shtml
AddHandler server-parsed .shtml
The main variables that need to be set are DocumentRoot and ScriptAlias.

Finally, the file access.conf is used to control global accesses. This file should also be in ServerRoot/conf/access.conf. Relevant parts are


# This should be changed to whatever you set DocumentRoot to.

<Directory /home/httpd/html>

# /home/httpd/cgi-bin should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.

<Directory /home/httpd/cgi-bin>
AllowOverride None
Options ExecCGI
</Directory>
You need to set the two Directory values.
Jan Newmarch (http://pandonia.canberra.edu.au)
jan@ise.canberra.edu.au
Last modified: Tue Aug 1 10:09:13 EST 2000
Copyright ©Jan Newmarch