The Red Hat httpd.conf File


The Red Hat httpd.conf File

This section highlights some of the important features of the Red Hat httpd.conf file, which is based on the httpd.conf file distributed by Apache. This heavily commented file is broken into the following parts (as is this section):

  1. Global Environment: Controls the overall functioning of the Apache server.

  2. Main Server Configuration: Configures the default server (as opposed to virtual hosts) and provides default configuration information for virtual hosts.

  3. Virtual Hosts: Configures virtual hosts. For more information refer to "Virtual Hosts" on page 818.

Section 1: Global Environment

ServerTokens


The ServerTokens directive (page 809) is set to OS, which causes Apache, when queried, to return the name of the operating system and the complete version number of Apache:

ServerTokens OS


ServerRoot


The ServerRoot directive (page 809) is set to /etc/httpd, which is the pathname that Apache prepends to relative pathnames in httpd.conf:

ServerRoot "/etc/httpd"


<IfModule>


Multiprocessing modules (MPMs) allow you to change the way Apache works by changing the modules it uses. The <IfModule> containers (page 800) allow you to use the same httpd.conf file with different modules: The directives in an <IfModule> container are executed only if the specified module is loaded.

The section of httpd.conf that starts with the comment

## Server-Pool Size Regulation (MPM specific)


holds two <IfModule> containers (page 800) that configure Apache, depending on which module, prefork or worker, is loaded. Red Hat ships Apache with the prefork module loaded; this section does not discuss the <IfModule> container for the worker module. (See the comments in the /etc/sysconfig/httpd file if you want to load the worker module.)

The prefork <IfModule> container, shown below, holds directives that control the functioning of Apache when it starts and as it runs:

<IfModule prefork.c> StartServers       8 MinSpareServers    5 MaxSpareServers   20 ServerLimit      256 MaxClients       256 MaxRequestsPerChild  4000 </IfModule>


Listen


FEDORA The Listen directive (page 795) does not specify an IP address.

RHEL The Listen directive specifies an IP address of 0.0.0.0, which is the same as not specifying an IP address, so Apache listens on all network interfaces.

Listen 80


LoadModule


There are quite a few LoadModule directives (page 811); these directives load the Apache DSO modules (page 820).

Include


The Include directive (page 810) includes the files that match *.conf in the /etc/httpd/conf.d directory, as though they were part of httpd.conf:

Include conf.d/*.conf


Red Hat test page


When you first install Apache, there is no index.html file in /var/www/html; when you point a browser at the local Web server, Apache generates error 403, which returns the Red Hat test page. The mechanism by which this page is returned is convoluted: The Red Hat httpd.conf file holds an Include directive that includes all files in the conf.d directory that is in the ServerRoot directory (page 809). The welcome.conf file in this directory contains an ErrorDocument 403 directive (page 807) that redirects users who receive this error to error/noindex.html in the Document-Root directory (page 796). The noindex.html file is the Red Hat test page that confirms the server is working but there is no content to display.

Section 2: Main Server Configuration

ServerAdmin, ServerName


As Red Hat Linux is shipped, the ServerAdmin and ServerName directives are commented out. Change them to useful values as suggested in the ServerAdmin (page 795) and ServerName (page 796) sections.

DocumentRoot


The DocumentRoot directive (page 796) appears as follows:

DocumentRoot "/var/www/html"


You need to modify this directive only if you want to put your content somewhere other than /var/www/html.

<Directory>


The following <Directory> container (page 799) sets up a restrictive environment for the entire local filesystem (specified by /):

<Directory />     Options FollowSymLinks     AllowOverride None </Directory>


The Options directive (page 811) allows Apache to follow symbolic links but disallows many options. The AllowOverride directive (page 813) causes Apache to ignore .htaccess files. You must explicitly enable less restrictive options if you want them, but be aware that doing so can expose the root filesystem and compromise system security.

Next another <Directory> container sets up less restrictive options for the DocumentRoot (/var/www/html). The code in httpd.conf is interspersed with many comments. Without the comments it looks like this:

<Directory "/var/www/html">     Options Indexes FollowSymLinks     AllowOverride None     Order allow,deny     Allow from all </Directory>


The Indexes option in the Options directive allows Apache to display directory listings. The Order (page 814) and Allow (page 812) directives combine to allow requests from all clients. This container is slightly less restrictive than the preceding one, although it still does not allow Apache to follow directives in .htaccess files.

DirectoryIndex


As explained on page 797, the DirectoryIndex directive causes Apache to return the file named index.php, index.html, index.htm, or index.shtml from a requested directory. Because Options Indexes is specified in the preceding <Directory> container, if none of these files exists in a queried directory, Apache returns a directory listing:

DirectoryIndex  index.php index.html index.htm index.shtml


There are many more directives in this part of the httpd.conf file. The comments in the file provide a guide as to what they do. There is nothing here you need to change as you get started using Apache.

Section 3: Virtual Hosts

All lines in this section are comments or commented-out directives. If you want to set up virtual hosts, see page 818.




A Practical Guide to Red Hat Linux
A Practical Guide to Red HatВ® LinuxВ®: Fedoraв„ў Core and Red Hat Enterprise Linux (3rd Edition)
ISBN: 0132280272
EAN: 2147483647
Year: 2006
Pages: 383

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net