Online Book Reader

Home Category

Running Linux, 5th Edition - Matthias Kalle Dalheimer [429]

By Root 1218 0
and build it yourself. The http://httpd.apache.org web site contains complete documentation for the software.

Apache: The Definitive Guide, by Ben Laurie and Peter Laurie (O'Reilly), covers everything about Apache, including sophisticated configuration issues.

Where the various files of an Apache installation go depends on your distribution or the package you installed, but the following is a common setup. You should locate the various pieces in your system before continuing.

/usr/sbin/httpd

The binary executable, which is the server itself. On Debian, this is /usr/ sbin/apache instead.

/etc/httpd

Contains the configuration files for httpd, most notably httpd.conf. We discuss how to modify these files later. On Debian systems, this is /etc/apache instead of /etc/httpd.

/usr/local/httpd

Contains the HTML scripts to be served up to the site's clients. This directory and those below it, the web space, are accessible to anyone on the Web and therefore pose a severe security risk if used for anything other than public data.

/var/log/httpd

Holds logfiles stored by the server.

Our task now is to modify the configuration files in the configuration subdirectory. You should notice at least the following four files in this directory: access.conf-dist, httpd.conf-dist, mime.types, and srm.conf-dist. (Newer versions of Apache 1.3.x have abandoned the -dist suffix in favor of the .default suffix, and Apache 2.x places a -std fragment before the extension.) Copy the files with names ending in -dist and modify them for your own system. For example, httpd.conf -dist is copied to httpd.conf and edited.

The latest version of Apache pretty much configures itself, but in case things go wrong, we tell you here how to do it manually so that you can fix things yourself.

At http://httpd.apache.org, you will find complete documentation on how to configure httpd. Here, we present sample configuration files that correspond to an actual running httpd.

httpd.conf

The file httpd.conf is the main server-configuration file. First, copy httpd.conf-dist to httpd.conf and edit it. We only cover some of the more important options here; the file httpd.conf-dist is vastly commented.

The ServerType directive is used to specify how the server will run—either as a standalone daemon (as seen here) or from inetd. For various reasons, it's usually best to run httpd in standalone mode. Otherwise, inetd must spawn a new instance of httpd for each incoming connection.

One tricky item here is the port number specification. You may wish to run httpd as a user other than root (that is, you may not have root access on the machine in question and wish to run httpd as yourself). In this case, you must use a port numbered 1024 or above. For example, if we specify:

Port 2112

we may run httpd as a regular user. In this case, HTTP URLs to this machine must be specified as in the following example:

http://www.ecoveggie.org:2112/...

If no port number is given in the URL (as is the usual case), port 80 is assumed.

With

DocumentRoot

/usr/local/httpd/htdocs

we specify the DocumentRoot directive, where documents to be provided via HTTP are stored. These documents are written in HTML.

For example, if someone were to access the URL:

http://www.ecoveggie.org/fruits.html

the actual file accessed would be /usr/local/httpd/htdocs/fruits.html.

The UserDir directive specifies a directory each user may create in his home directory for storing public HTML files. For example, if we were to use the URL:

http://www.ecoveggie.org/~mdw/linux-info.html

the actual file accessed would be ~mdw/public_html/linux-info.html.

The following lines enable the indexing features of httpd :

# If a URL is received with a directory but no filename, retrieve this

# file as the index (if it exists).

DirectoryIndex index.html

# Turn on 'fancy' directory indexes

IndexOptions FancyIndexing

In this case, if a browser attempts to access a directory URL, the file index.html in that directory is returned, if it exists. Otherwise, httpd generates a "fancy" index

Return Main Page Previous Page Next Page

®Online Book Reader