Apache Configuration Files

Kinds of Configuration Files

There are various kinds of configuration files. Some of them are:

Configuration FilesDescription
Charset.convThis file tells which character set is to be used for different languages.
conf.d/*.confIt is added by other modules which are included into virtual host configuration when required.
default-server.confThis file is a Global configuration file that consists of default value. However, these default values can be overwritten when required.
errors.confSpecifies how Apache responds to errors.
listen.confThis file binds Apache to specific IP addresses and ports.
httpd.confThis is the main Apache server configuration file that contains “global settings” and “include statements”.
mod_*.confIt contains modules that are installed by default.
mime.typesIt contains MIME types that are familiar to the system.
ssl-global.conf and ssl.*Both the files contain Global SSL configuration and SSL certificate data.
uid.confIt states the user and group ID under which Apache runs.
vhosts.d/*.confIt consists of virtual host configuration data.

httpd.conf Configuration File

  • The httpd.conf is a configuration file.
  • It is used by the Apache HTTP Server.
  • Apache server looks at this file for different configuration properties.
  • It is stored in path : /etc/httpd/conf/httpd.conf.
  • The default configuration of httpd.conf includes all types of directives and it works well for most systems.

How to edit httpd.conf file ?

  • Copy the original file to some other file and create a backup. This will help you recover any mistakes while editing the file.
  • If any mistakes are found in httpd.conf file, the web server will not work properly.
  • To edit httpd.conf file open the file through editor like “vi editor”, so that you can make changes in it.
  • After editing, reload the file or stop and start httpd process.
  • To reload the server configuration file type use /service httpd reload command.
  • To start the server configuration file type use /service httpd start command.
  • To stop the server configuration file type use /service httpd stop command.
  • To restart (stop and start) the server configuration file type use /service httpd restart command.

  • If web server does not work properly, then you have made some typo mistakes. Check the latest entries in the web server's error log stored at /var/log/httpd/error_log to see the errors.

Configuration Directives in httpd.conf

ServerRoot
It specifies the top level directory containing website content. Both your secure and non-secure servers are set to ServerRoot of “/etc/httpd”.

PidFile
PidFile names the file where server stores its process ID (Pid). By default, pid is listed in /var/run/httpd.pid.

LockFile
It sets the path to the lockfile. It is used when httpd is compiled with either USE_FCNTL_SERIALIZED_ACCEPT or USE_FLOCK_SERIALIZED_ACCEPT.

Timeout
Timeout sets the amount of time in seconds that your server will wait for response and transmissions during communications. By default, it is set to 300 seconds, which is appropriate for most situations.

KeepAlive
It sets whether the server allows more than one request per connection and can be used to prevent a client from using too much of the servers resources. By default, KeepAlive is set to off that means server does not allow continuous connections.

MaxKeepAliveRequests
MaxKeepAliveRequests sets the maximum number of requests allowed per persistent connections. It is set to 100 by default, which should be suitable for most situations.

KeepAliveTimeout
This directive sets the number of seconds your server will wait for next request, after a request has been served before it closes the connection. By default, it is set to 15 seconds.

StartServers
This directive sets how many server processes are created upon startup. The Web server is set to start 8 server processes at startup.

MaxClients
Maxclients sets a limit on the total number of server processes that can run simultaneously at one time. The main purpose of this directive is to keep a runaway web server from crashing the operating system. By default, it is set to 150.

LoadModule
This directive is used to load in Dynamic Shared Object (DSO) modules. The order of modules is important.

User
It sets the userid used by the server to answer the requests. User is not allowed to execute any code that is not intended to be in response to HTTP requests. By default, User is set to Apache.

Group
It is similar to the User. The Group sets the groupid under which the server will answer requests. By default, Group is set to Apache.

ServerName
It specifies a hostname and port number for the server. ServerName which is different from the server's real host name. ServerName must be a valid DNS (Domain Name Service).

Options
It controls which server features are available in a particular directory. By default, it is set to 'FollowSymLinks' which means that server is allowed to follow symbolic links in the root directory.

Allow
Allow specifies which requester can access a given directory. The requester can be all, an IP address, a domain name, a partial IP address, a network/netmask pair. By default, it is set to all.

Deny
Deny is similar to Allow. It specifies which requester is denied from access. The requester can be all, an IP address, a domain name, a partial IP address, a network/netmask pair.

LogLevel
LogLevel can be set from least verbose to most verbose. It sets how verbose the error messages in the error logs can be.

LogFormat
LogFormat sets up a format for the messages in your access log.

CustomLog
CustomLog identifies the log file and its log file format.

ServerSignature
This directive adds line containing the Apache server version and ServerName of the serving host to any server generated documents. The default ServerSignature is set to 'On'.

AddType
AddType directive is used to define MIME type and file extension pairs. For instance, web server identifies .php4, .php3, .phtml, .php as PHP MIME types.

AddHandler
This directive maps file extensions to specific handlers.

For Example
The cgi-script handler is matched with an extension .cgi for which the format is
AddHandler cgi-script .cgi

Action
It contains a MIME content type and CGI script pair, so that if a file of that media type is requested, a particular CGI script is executed.

LanguagePriority
It sets precedence for different languages.