apache2.conf file

In Ubuntu, the main Apache2 configuration file that contains settings global to Apache is /etc/apache2/apache2.conf. This file contains a set of directives, which are instructions that tell Apache what to do. Most directives are followed by an argument, which is the data passed to the directive. Here is a description of the directives found in this file:

  • ServerRoot – specifies where Apache configuration files and modules are kept. This server root directory is then used as a prefix to other directory entries.
  • Mutex file – sets the mechanism and the lock file location, that httpd and modules use to serialize access to resources.
  • PidFile – specifies the server’s process ID (PID) file. On Ubuntu, the PID is defined by the APACHE_PID_FILE variable in the /etc/apache2/envvars file.
  • Timeout – specifies the number of seconds before the web server times out a send or receive request.
  • KeepAlive – if set to On, this option will allow each connection to remain open to handle multiple requests from the same client. If set to Off (which is the default), each request will have to establish a new connection.
  • MaxKeepAliveRequests – specifies the maximum number of requests on a persistent connection.
  • KeepAliveTimeout – specifies the time that a given connection to a client is kept open to receive more requests from that client.
  • User – specifies the user that run Apache. The user is defined by the APACHE_RUN_USERS variable in the /etc/apache2/envvars file (by default it is www-data).
  • Group – specifies the group that run Apache. The group is defined by the APACHE_RUN_GROUP variable in the /etc/apache2/envvars file (by default it is www-data).
  • HostnameLookups – specifies whether the DNS lookups should be enabled so that host names can be logged. Turned off by default.
  • ErrorLog – specifies the location of the error log file. The location is defined by the APACHE_LOG_DIR variable in the /etc/apache2/envvars file.
  • LogLevel – specifies the level at which messages will be logged. The warn level is the default, but you can choose others like notice, info, debug, crit, alert, and emerg.
  • IncludeOptional & Include – enable inclusion of other configuration files. such as module, port, and site configuration files.
  • <Directory />…</Directory> – enables you to define a block of directives that apply only to a particular directory. The first directory definition applies rules for the root directory (/).
  • AccessFileName – specifies the name of the file to look for in each directory for additional configuration directives. The default value of this directive is .htaccess.
  • <FilesMatch “^\.ht”> Require all denied </FilesMatch> – denies access to the .htaccess files by Web clients.
  • LogFormat – defines some nicknames to be used with the CustomLog directive, such as host_combined, common, and referrer. The CustomLog directive defines a default log for virtual hosts that don’t define one.


Don’t worry if you don’t understand the purpose of some of the directives described above; we will go through most of them in the next chapters.
Geek University 2022