srm.conf defines server settings which affect how requests are serviced, and how results should be formatted. NEW denotes new features/changes to NCSA httpd 1.3.
This is used to define the directory which Apache will use as the default directory in which to search for documents.
DocumentRoot /usr/local/httpd/htdocs
Would set the document root such that, for example,
http://www.foo.bar.com/index.html
refers to
/usr/local/httpd/htdocs/index.html
In order to allow regular users to set up HTML pages of their own, you may want to allow the users to create and maintain the pages in their own system. However, for security reasons, it's unwise to allow the outside world to see all files in a user's filespace.
UserDir
can be used to force all regular user
filespace to be unreachable, with only one directory (the one named
here) visible to the outside world.
e.g. if UserDir
is set to
public_html
, then,
http://www.foo.bar.com/~fred/index.html
would refer to
/users/staff/fred/public_html/index.html
and /users/staff/fred/
would be safe from
prying eyes.
SECURITY: Using UserDir
exposes your
users user-ids to the outside world. Some people consider this to be
unwise.
(n.b. this extends the NCSA httpd 1.3 syntax to allow multiple filenames)
It is customary to have a file in each directory which indexes or
describes the rest of the directory contents. Most people use the
filename index.html
for this purpose, and as a
shortcut, when referencing this file, the filename is omitted. So,
http://www.foo.bar.com/docs/
implicitly refers to
http://www.foo.bar.com/docs/index.html
Apache allows you to define any number of these special filenames, and Apache will search for each in turn, until it finds a match or it has exauhsted all the filenames. e.g.
DirectoryIndex index.html index.txt
Typically, you'll set DirectoryIndex
to
index.html
. You may want to set it to
index
, thus allowing content-negotiation to work for an HTML
2.0 document named "index.html" and an HTML 3.0 document named
"index.html3".
This is a toggle switch between what is called fancy indexing and standard indexing.
As the name suggests, fancy indexing looks more impressive. Use either
FancyIndexing on
or
FancyIndexing off
These two are used for FancyIndexing.
They define icons to be used to represent file types, the types are defined via the MIME types file and/or file extensions.
Most admins won't want to or need to change these.
Each directory available to Apache, can be configured with its own access configuration. This per-directory access configuration overrides the server wide access settings.
Apache looks for a file in each directory to read the override access information for that directory.
AccessFileName
defines the name of the filename
that Apache should look for. The convention is to call this file
.htaccess
, but you can set it to whatever you want,
e.g. to set it to access.override
...
AccessFileName access.override
There will be times when Apache is asked to provide a document whose type cannot be determined by Apache's MIME types mappings.
Apache must inform the client of the
Content-type
of the document, so in the event of
an unknown type, Apache uses DefaultType
.
It's probably best to set Content-type
to
text/plain
, but you are free to choose any type
you want, e.g. you might prefer to set it to
image/gif
if your site serves lots of gif images
with filenames missing the .gif extension.
One can define MIME type mappings for Apache in the
conf/mime.types
file or in
srm.conf
.
It is recommended that server specific mime types are defined in
srm.conf
and that
conf/mime.types
be left unaltered.
Here's an example of how to define some new mime types for use by Apache:
AddType image/gif gif GIF AddType application/postscript ps post AddType text/plain ascii
When serving documents, it is often convinient (and good netiquette) to compress them if they are particularly large.
Compressed files have their own MIME type which can be sent by Apache, but ideally, we want to tell the client that the document is compressed, but also of a particular mime type too. That way, the client can uncompress and handle the document in the intended format, instead of as a default type.
AddEncoding
can be used to achieve the above.
It works by sending the client additional information to describe the
encoding mechanism used. e.g. in this way, Apache can tell a client
that a file called paper.ps.Z is of type
application/postscript
with
Content-encoding: x-compress
The distribution file gives the examples
AddEncoding x-gzip gz AddEncoding x-compress Z
Comment or uncomment these as necessary.
For various reasons, e.g. things move from site to site and URLs change. Rather than have the client find nothing, it is sometimes better to give them a pointer to the new URL.
The Redirect
option maps an old URL into a new
one. e.g. to redirect the client to
http://foo2.bar.com/service/, after it asked for
/service/, one could use,
Redirect /service/ http://foo2.bar.com/service/
Aliases are useful for renaming old URLs and for shortening long URLs.
Apache aliasing does a simple substitution of a URL prefix with a filesystem path. e.g. we can define an alias called /shortcut/ to map to /fred/long/path/to/some/resource/ with the following,
Alias /shortcut/ /usr/local/httpd/htdocs/fred/long/path/to/some/resource/
Note that we have to use the absolute file path in the alias we are mapping to.
For similar reasons listed for Alias, it is often convenient to have URLs for scripts accessed via an alias.
As with Alias, the mapping is from the URL prefix to the aboslute path, e.g.
ScriptAlias /go/ /usr/local/httpd/cgi-bin/go-code/
This feature is NEW in Apache, though it will probably be in NCSA 1.4.
In the event of a problem or error, Apache can be configured to do one of four things,
1-3 are configured using ErrorDocument
, which
is followed by the HTTP response code and a message or URL.
Messages in this context, begin with a single quote ("), which does not form part of the message itself. Apache will sometime offer additional information regarding the problem/error. This can be embedded into the message using %s
URLs will begin with a slash (/) for local URLs, or will be a full URL which the cleint can resolve.
examples,
ErrorDocument 500 /cgi-bin/tester ErrorDocument 404 /cgi-bin/bad_urls.pl ErrorDocument 401 http://www2.foo.bar/subscription_info.html ErrorDocument 403 "Sorry can't allow you access today
See Also: documentation of customizable responses