Directives to Add New Sites

The following directives are part of a httpd.conf file . They are used for adding new sites i.e. features for the server in the httpd.conf file.

1. Document Root
It contains HTML files which are served in response to requests. The default DocumentRoot is set to /var/www/html.

Example : Document Root

Server receives a request for the following document

Server finds for the following file in the default directory

2. Directory
<Directory /path/to/directory> and </Directory> tags are used to enclose a group of configuration directives which apply only to that directory and all of its subdirectories.

Example : Directory

If CGI scripts are stored in /home/my_cgi_directory, add the following directory container to httpd.conf file

<Directory /home/my_cgi_directory>
    Options +ExecCGI

3. ErrorLog
It specifies the file where server errors are logged. By default, it is set to “/var/log/httpd/error_log”.
4. Listen
It identifies the ports on which server will accept incoming requests. By default, it is set to  port 80 and port 443 for both non-secure and secure web communications.
5. Location
The <Location> and </Location> tags allow you to specify the access control based on URL.

Example : Location

If you allow people to see status report, use the following directives

<Location /server-status>
     SetHandler server-status
     Order deny,allow
     Deny from all
     Allow from <>

6. Redirect
If a web page is moved, redirecting helps in mapping the old URL to a new URL.

Redirect /path/CareerRide.html http://new_domain/path/CareerRide.html

7. VirtualHost
  • The <VirtualHost> and </VirtualHost> tags outline the characteristics of a virtual host.
  • It accepts most configuration directives.
  • It refers to Apache's ability to serve multiple universal resource identifiers (URIs) from the same physical machine.
  • It means several domains such as and, are run by a single web server on a single physical machine.
Advantages of VirtualHost
  • It saves administrative effort.
  • It requires only a single web server to be maintained.
  • It saves hardware expenses.
  • In VirtualHost each domain does not require a dedicated server.
8. Modules
  • Modules allow the activation or deactivation of the script languages.
  • They are only allowed for use in web server.
  • Apache software is built in modular fashion.
  • Most of the tasks are handled by modules.
Apache modules are divided into four different types

1. Base Modules: By default, these modules are compiled into Apache.
2. Extension Modules: In Apache software package these modules are included, but not compiled into the server statically.
3. External Modules: External modules are not included in the official Apache distribution.
4. Multiprocessing Modules (MPMs): These modules are responsible for accepting and handling requests to the web server, representing the core of the web server software.