Other housekeeping directives are listed here.
ServerName hostname Server config, virtual host
ServerName gives the hostname of the server to use when creating redirection URLs, that is, if you use a <Location> directive or access a directory without a trailing "/".
UseCanonicalName on|off Default: on Server config, virtual host, directory, .htaccess
This directive controls how Apache forms URLs that refer to itself, for example, when redirecting a request for http://www.domain.com/some/directory to the correct http://www.domain.com/some/directory/ (note the trailing "/" ). If UseCanonical-Name is on (the default), then the hostname and port used in the redirect will be those set by ServerName and Port. If it is off, then the name and port used will be the ones in the original request.
One instance where this directive may be useful is when users are in the same domain as the web server (for example, on an intranet). In this case, they may use the "short" name for the server (www, for example), instead of the fully qualified domain name (www.domain.com, say). If a user types a URL such as http://www/somedir (without the trailing slash), then, with UseCanonicalName switched on, the user will be directed to http://www.domain.com/somedir/, whereas with UseCanonicalName switched off, he or she will be redirected to http://www/somedir/. An obvious case in which this is useful is when user authentication is switched on: reusing the server name that the user typed means they won't be asked to reauthenticate when the server name appears to the browser to have changed. More obscure cases relate to name/address translation caused by some firewalling techniques.
ServerAdmin email_address Server config, virtual host
ServerAdmin gives Apache an email_address for automatic pages generated when some errors occur. It might be sensible to make this a special address such as server_probs@butterthlies.com.
ServerSignature [off|on|email] Default: off Directory, .htaccess
This directive allows you to let the client know which server in a chain of proxies actually did the business. ServerSignature on generates a footer to server-generated documents that includes the server version number and the ServerName of the virtual host. ServerSignature email additionally creates a mailto: reference to the relevant ServerAdmin address.
ServerTokens [min(imal)|OS|full] Default: full Server config
This directive controls the information about itself that the server returns:
Server returns name and version number, for example, Apache v1.3
Server sends operating system as well, for example, Apache v1.3 (Unix)
Server sends the previously listed information plus information about compiled modules, for example, Apache v1.3 (Unix) PHP/3.0 MyMod/1.2
ServerAlias name1 name2 name3 ... Virtual host
ServerAlias gives a list of alternate names matching the current virtual host. If a request uses HTTP 1.1, it arrives with Host: server in the header and can match ServerName, ServerAlias, or the VirtualHost name.
ServerPath path Virtual host
In HTTP/1.1 you can map several hostnames to the same IP address, and the browser distinguishes between them by sending the Host header. But it was thought there would be a transition period during which some browsers still used HTTP/1.0 and didn't send the Host header.[28] So ServerPath lets the same site be accessed through a path instead.
[28]Note that this transition period was almost over before it started because many browsers sent the Host header even in HTTP/1.0 requests. However, in some rare cases, this directive may be useful.
It has to be said that this directive often doesn't work very well because it requires a great deal of discipline in writing consistent internal HTML links, which must all be written as relative links to make them work with two different URLs. However, if you have to cope with HTTP/1.0 browsers that don't send Host headers accessing virtual sites, you don't have much choice.
For instance, suppose you have site1.somewhere.com and site2.somewhere.com mapped to the same IP address (let's say 192.168.123.2), and you set up the httpd.conf file like this:
<VirtualHost 192.168.123.2> ServerName site1.somewhere.com DocumentRoot /usr/www/site1 ServerPath /site1 </VirtualHost> <VirtualHost 192.168.123.2> ServerName site2.somewhere.com DocumentRoot /usr/www/site2 ServerPath /site2 </VirtualHost>
Then an HTTP/1.1 browser can access the two sites with URLs http://site1. somewhere.com / and http://site2.somewhere.com /. Recall that HTTP/1.0 can only distinguish between sites with different IP addresses, so both of those URLs look the same to an HTTP/1.0 browser. However, with the above setup, such browsers can access http://site1.somewhere.com/site1 and http://site1.somewhere.com/site2 to see the two different sites (yes, we did mean site1.somewhere.com in the latter; it could have been site2.somewhere.com in either, because they are the same as far as an HTTP/1.0 browser is concerned).
ServerRoot directory Default directory: /usr/local/etc/httpd Server config
ServerRoot specifies where the subdirectories conf and logs can be found. If you start Apache with the -f (file) option, you need to include the ServerRoot directive. On the other hand, if you use the -d (directory) option, as we do, this directive is not needed.
PidFile file Default file: logs/httpd.pid Server config
A useful piece of information about an executing process is its PID number. This is available under both Unix and Win32 in the PidFile, and this directive allows you to change its location. By default, it is in ... /logs/httpd.pid. However, only Unix allows you to do anything easily with it; namely, to kill the process.
ScoreBoardFile filename Default: ScoreBoardFile logs/apache_status Server config
The ScoreBoardFile directive is required on some architectures in order to place a file that the server will use to communicate between its children and the parent. The easiest way to find out if your architecture requires a scoreboard file is to run Apache and see if it creates the file named by the directive. If your architecture requires it, then you must ensure that this file is not used at the same time by more than one invocation of Apache.
If you have to use a ScoreBoardFile, then you may see improved speed by placing it on a RAM disk. But be aware that placing important files on a RAM disk involves a certain amount of risk.
Apache 1.2 and above: Linux 1.x and SVR4 users might be able to add
-DHAVE_SHMGET
-DUSE_SHMGET_SCOREBOARD to the
EXTRA_CFLAGS in your Config file. This might work
with some 1.x installations, but not with all of them. (Prior to
1.3b4, HAVE_SHMGET would have sufficed.)
CoreDumpDirectory directory Default: <serverroot> Server config
Specifies a directory where Apache tries to dump core. The default is
the ServerRoot directory, but this is normally
not writable by Apache's user. This directive is useful only in
Unix, since Win32 does not dump a core after a crash.
SendBufferSize <number> Default: set by OS Server config
Increases the send buffer in TCP beyond the default set by the operating system. This directive improves performance under certain circumstances, but we suggest you don't use it unless you thoroughly understand network technicalities.
LockFile <path>directory Default: logs/accept.lock Server config
When Apache is compiled with
USE_FCNTL_SERIALIZED_ACCEPT or
USE_FLOCK_SERIALIZED_ACCEPT, it will not start
until it writes a lock file to the local disk. If the
logs directory is NFS mounted, this will not be
possible. It is not a good idea to put this file in a directory that
is writable by everyone, since a false file will prevent Apache from
starting. This mechanism is necessary because some operating systems
don't like multiple processes sitting in
accept() on a single socket (which is where Apache
sits while waiting). Therefore, these calls need to be serialized.
One way is to use a lock file, but you can't use one on an
NFS-mounted directory.
KeepAlive number Default number: 5 Server config
The chances are that if a user logs on to your site, he or she will reaccess it fairly soon. To avoid unnecessary delay, this command keeps the connection open, but only for number requests, so that one user does not hog the server. You might want to increase this from 5 if you have a deep directory structure. Netscape Navigator 2 has a bug that fouls up keepalives. Apache from v1.2 on can detect the use of this browser by looking for Mozilla/2 in the headers returned by Netscape. If the BrowserMatch directive is set (see Chapter 4, "Common Gateway Interface (CGI) "), the problem disappears.
KeepAliveTimeout seconds Default seconds: 15 Server config
Similarly, to avoid waiting too long for the next request, this directive sets the number of seconds to wait for the next request. Once the request has been received, the TimeOut directive applies.
TimeOut seconds Default seconds: 1200 Server config
Sets the maximum time that the server will wait for the receipt of a request and then its completion block by block. This directive used to have an unfortunate effect: downloads of large files over slow connections used to time out. The directive has, therefore, been modified to apply to blocks of data sent rather than to the whole transfer.
HostNameLookups [on|off|double] Default: off[29] Server config, virtual host
If this directive is on, then every incoming connection is reverse DNS resolved, which means that, starting with the IP number, Apache finds the hostname of the client by consulting the DNS system on the Internet. The hostname is then used in the logs. If switched off, the IP address is used instead. It can take a significant amount of time to reverse resolve an IP address, so for performance reasons it is often best to leave this off, particularly on busy servers. Note that the support program logresolve is supplied with Apache to reverse resolve the logs at a later date.[30]
[30]Dynamically allocated IP addresses may not resolve correctly at any time other than when they are in use. If it is really important to know the exact name of the client, HostNameLookups will have to be set to on.
The new double keyword supports the double-reverse DNS test. An IP address passes this test if the forward map of the reverse map includes the original IP. Regardless of the setting here, mod_access access lists using DNS names require all the names to pass the double-reverse test.
Include filename Server config
filename points to a file that will be included in the Config file in place of this directive.
Copyright © 2001 O'Reilly & Associates. All rights reserved.