Configuring Apache
Configuration Files
The configuration files determine the web site policies and behaviors.
httpd.conf
- Sets up the server daemon -- port number, user ID, etc.
srm.conf
- Sets root of the document tree, special handlers, etc.
access.conf
- Sets access restrictions, etc.
mime.types
- Translates filename extensions to
Content-Type
headers sent to the browser
- Covered later
On Unix, the config files can be combined
- Makes administration easier
- A feature that can be enabled.
On Win32, they are combined by default into httpd.conf.
Each line in these files specifies a configuration parameter,
called a
directive.
Example -- the ServerAdmin directive:
# Your address, where problems with the server
# should be e-mailed.
# This address appears on some server-generated pages,
# such as error documents.
#
ServerAdmin webmaster@keller.com
|
Example Policies and Behaviors
- Whether and how users have their own web directories (commonly, Unix only)
- Default:
public_html
- Mapped to
~user in the URL
http://www.mynet.com/~mary would be mapped
to /home/mary/public_html
- Can be changed with the
UserDir
directive in access.conf
- For example:
UserDir /home/httpd
would map /~mary/ to /home/httpd/mary.
- This enables you to have a completely distinct directory
tree for user web pages.
- Rarely applicable under Win32 (users don't usually have "home" directories)
- Whether to process
PUT and DELETE commands
- Web servers all process
GET commands (requests for pages)
and POST commands (form submissions)
- Newer authoring tools upload files with the
PUT
command (an improvement over FTP)
- By default, Apache doesn't process these commands.
- If you use a newer authoring tool, you can
configure
Apache to process
PUT and DELETE
- Which request parameters to record in the log file.
- By default, Apache doesn't log the
referer
(where the browser "came from")
- By default, Apache doesn't log the
user-agent
(which browser the document requestor used)
- More about logging later
- The port number at which to listen
- Specified in the URL as, e.g.
http://www.mynet.com:8111
- By default, port 80, the standard
port number for the web
- Other numbers can be used.
Why might you do this? (Answer)
- Configured in
httpd.conf in the
Port
directive
- Port numbers below 1024 are "system" ports and servers can use them only
if they're run by
root.
| Lab |
|---|
- Go to the
C:\Program Files\Apache Group\Apache\conf directory.
- Peruse each of the four configuration files in a text editor.
- Select one of the parameters defined in
httpd.conf
and look up its meaning in the on-line Apache manual.
- Set the
ServerName
to your server's name.
- Set the
ServerAdmin
to your e-mail address.
- Turn
HostnameLookups On
(to make your logs more legible).
- Modify the
Port
so that your server listens to port 8111.
- Stop and restart your server.
- Does your server respond to requests at port 80 anymore?
- Does it respond to requests at the new port number?
- Change your port number back to 80, and stop and restart your server.
- Change your document root to
C:\web
- Create this directory.
- Create your own server home page (
index.html) in it.
- Modify the
DocumentRoot
directive.
- Stop and restart your server.
- See that the new home page is shown in your browser.
|
Configuration File Validation
- When you edit your configuration files,
before you fire up your server
it's a good idea to make sure you haven't
mangled them.
- Use Apache's config file syntax checker.
- On Unix:
# /usr/local/web/apache/bin/apachectl configtest
Syntax OK
- On Windows:
C:\Program Files\Apache Group\Apache> apache -t
c:/program files/apache group/apache/conf/httpd.conf: Syntax OK
| Lab |
|---|
- Check the syntax of your config files.
- Mangle one and check again.
- Then fix it.
|