14.3 Configuring the Apache HTTP Server

Note

Any changes that you make to the configuration of the Apache HTTP server do not take effect until you restart the server:

# service httpd restart

The main configuration file for the Apache HTTP server is /etc/httpd/conf/httpd.conf. You can modify the directives in this file to customize Apache for your environment.

The directives include:

Allow from client [client ...] | all

Specifies a list of clients that can access content or all to serve content to any client. The Order directive determines the order in which httpd evaluates Allow and Deny directives.

Deny from client [client ...] | all

Specifies a list of clients that cannot access content or all to disallow all clients. The Order directive determines the order in which httpd evaluates Allow and Deny directives.

DocumentRoot directory-path

The top level directory for Apache server content. The apache user requires read access to any files and read and execute access to the directory and any of its sub-directories. Do not place a slash at the end of the directory path.

For example:

DocumentRoot /var/www/html
ErrorLog filename | syslog[:facility]

If set to a file name, specifies the file, relative to ServerRoot, to which httpd sends error messages.

If set to syslog, specifies that httpd send errors to rsyslogd. A facility argument specifies the rsyslogd facility. The default facility is local7.

For example:

ErrorLog logs/error_log 
Listen [IP_address:]port

Accept incoming requests on the specified port or IP address and port combination. By default, the httpd server accepts requests on port 80 for all network interfaces. For a port number other than 80, HTTP requests to the server must include the port number.

For example:

Listen 80
Listen 192.168.2.1:8080
LoadModule module path

The Apache HTTP server can load external modules (dynamic shared objects or DSOs) to extend its functionality. The module argument is the name of the DSO, and filename is the path name of the module relative to ServerRoot.

For example:

LoadModule auth_basic_module modules/mod_auth_basic.so
Order deny,allow | allow,deny

Specifies the order in which httpd evaluates Allow and Deny directives.

For example, permit access only to clients from the mydom.com domain:

Order deny,allow
Deny from all
Allow from .mydom.com

The following directives would not permit access by any client:

Order allow,deny
Deny from all
Allow from .mydom.com
ServerName FQDN[:port]

Specifies the fully qualified domain name or IP address of the httpd server and an optional port on which the server listens. The FQDN must be resolvable to an IP address. If you do not specify a FQDN, the server performs a reverse-name lookup on the IP address. If you do not specify a port, the server uses the port corresponding to the incoming request.

For example:

ServerName www.mydom.com:80
ServerRoot directory-path

The top of the directory hierarchy where the httpd server keeps its configuration, error, and log files. Do not place a slash at the end of the directory path.

For example:

ServerRoot /etc/httpd 
Timeout seconds

Specifies the number of seconds that httpd waits for network operations to finish before reporting a timeout error. The default value is 60 seconds.

UserDir directory-path ... | disabled [user ...] | enabled user ...

If set to disabled, disallows users identified by the space-separated user argument to publish content from their home directories. If no users are specified, all users are disallowed.

If set to enabled, allows users identified by the space-separated user argument to publish content from their home directories, provided that they are not specified as an argument to disabled.

directory-path is the name of a directory from which httpd publishes content. A relative path is assumed to be relative to a user’s home directory. If you specify more than one directory path, httpd tries each alternative in turn until find a web page. If directory-path is not defined, the default is ~/public_html. Do not place a slash at the end of the directory path.

For example:

UserDir disabled root guest
UserDir enabled oracle alice
UserDir www http://www.mydom.com/

The root and guest users are disabled from content publishing. Assuming that ServerName is set to www.mydom.com, browsing http://www.example.com/~alice displays alice's web page, which must be located at ~alice/www or http://www.example.com/alice (that is, in the directory alice relative to ServerRoot).

Note

You would usually change the settings in the <IfModule mod_userdir.c> container to allow users to publish user content.

For more information, see http://httpd.apache.org/docs/current/mod/directives.html.