Networking / Beginners

Basic Server Directives

A few directives define basic information about the server itself. We modified two of these, ServerAdmin and ServerName, when creating the basic configuration.

ServerAdmin defines the e-mail address of the web server administrator. In the default Red Hat configuration, this is set to root@localhost on the assumption that there is always a root account, and there is always the hostname localhost. Change this to the full e-mail address of the real web administrator.

For example:

ServerAdmin webmaster@www.example.org

In this example, we use the classic web adminitrator e-mail address webmaster@www.example.org as the value for ServerAdmin. For this to work, we need a webmaster entry in the sendmail aliases file.

ServerName defines the hostname returned to clients when they read data from this server. In the default Red Hat configuration, ServerName was commented out, and the example on the comment line set ServerName to localhost. Change this to provide a real hostname. For example:

ServerName www.example.org

When the ServerName directive is commented out, the "real" hostname is sent to clients. Thus, if the name assigned to the first network interface is joe.example.org, it is the name sent to clients when ServerName is undefined. Defining an explicit value for ServerName documents the configuration, and ensures that you get exactly the value you want. We set ServerName to www.example.org so that, even though the web server is running on wren, the server will be known as www.example.org during web interactions. Of course, www.example.org must be a valid hostname configured in DNS.

The UseCanonicalName directive controls whether or not the value defined by ServerName is used. UseCanonicalName defines how httpd handles "self-referencing" URLs, which refer back to the server. When this is set to on, as it is in the Red Hat configuration, the value in ServerName is used. If it is set to off, the value that came in the query from the client is used. If your site uses multiple hostnames, you may want to set this to off so that the user will see the name they expect in the reply.

The ServerRoot option defines the directory that contains the httpd server files. This is different from DocumentRoot, which is the directory that contains the information files the server presents to clients. On Red Hat, and most other systems, this is /etc/httpd. The conf directory under the ServerRoot contains the three configuration files. Therefore, httpd.conf is itself located under the ServerRoot that it defines.

The ServerType option defines how the server is started. If the server starts from a startup script at boot time, the option is set to standalone. If the server is run on demand by inetd or xinetd, ServerType is set to inetd. Most of the time, web servers are in high demand, so it is best to start them at boot time. It is possible, however, for a user to set up a small, rarely used website on a Linux desktop. In that case, running the server from inetd or xinetd may be desirable.

Port defines the TCP port number used by the server. The standard number is 80. On occasion, private web servers run on other port numbers. 8080 and 8000 are popular alternative ports for private websites. If you change the number, you must then tell your users the non-standard port number. For example, http://private.example.org:8080 is a URL for a website running on TCP port 8080 on host private.example.org.

When ServerType is set to inetd, it is usually desirable to set Port to something other than 80. The reason for this is that the ports under 1024 are "privileged" ports. If 80 is used, httpd must be run from inetd with the user ID root. This is a potential security problem, because an intruder might be able to exploit the website to get root access. Using port 80 is okay when ServerType is standalone because the initial httpd process does not provide direct client service. Instead, it starts several other HTTP daemons to provide client services that do not run with root privilege.

[Previous] [Contents] [Next]