Skip to content

Apache Server Files and Common Configuration Directives

Updated 6 min read

Updated: 22 October 2026 · Applies to: Apache 2.4.63 (httpd) on AlmaLinux 10.2 and Apache 2.4.66 (apache2) on Ubuntu 26.04, tested; the same layouts are used on Rocky Linux and RHEL 9 and 10, Debian 13 and Ubuntu 24.04

Apache keeps its server files in one of two layouts. On AlmaLinux, Rocky Linux and RHEL the package is httpd: the main file is /etc/httpd/conf/httpd.conf, extra settings go in /etc/httpd/conf.d/*.conf, websites live in /var/www/html and logs in /var/log/httpd/. On Debian and Ubuntu the package is apache2: the main file is /etc/apache2/apache2.conf, websites are virtual hosts in /etc/apache2/sites-available/, and logs go to /var/log/apache2/. After any change, run apachectl configtest and reload Apache.

Apache server files on AlmaLinux, Rocky Linux and RHEL

  • /etc/httpd/conf/httpd.conf: the main configuration file (the ServerRoot is /etc/httpd).
  • /etc/httpd/conf.d/*.conf: your own files, such as virtual hosts and SSL settings. Files here survive package updates.
  • /etc/httpd/conf.modules.d/*.conf: LoadModule lines for the modules.
  • /etc/httpd/logs, modules and run: links to /var/log/httpd, /usr/lib64/httpd/modules and /run/httpd.
  • /var/www/html: the default document root. Apache runs as the user apache.

Apache server files on Debian and Ubuntu

  • /etc/apache2/apache2.conf: the main file. ports.conf holds the Listen lines.
  • sites-available/ and sites-enabled/: virtual hosts. Enable one with a2ensite, disable it with a2dissite.
  • mods-available/ and mods-enabled/: modules, switched with a2enmod and a2dismod.
  • conf-available/ and conf-enabled/: global snippets, switched with a2enconf and a2disconf.
  • /etc/apache2/envvars: sets the user (www-data), the log folder (/var/log/apache2) and the run folder.
  • /var/www/html: the default document root.

See which files Apache really reads

Ask Apache instead of guessing. Use httpd or apachectl on the RHEL family and apache2ctl on Debian and Ubuntu:

httpd -V | grep -E 'HTTPD_ROOT|SERVER_CONFIG_FILE'
apachectl -t -D DUMP_INCLUDES
apachectl -S

DUMP_INCLUDES lists every file that is loaded and the line that includes it. -S shows the virtual hosts with the file and line of each, the main DocumentRoot, the error log and the user. Lab example from Ubuntu 26.04 (shortened):

apache2ctl -t -D DUMP_INCLUDES

Output:

Included configuration files:
  (*) /etc/apache2/apache2.conf
    (146) /etc/apache2/mods-enabled/access_compat.load
    ...
    (150) /etc/apache2/ports.conf
    (222) /etc/apache2/conf-enabled/security.conf
    (225) /etc/apache2/sites-enabled/000-default.conf

On Ubuntu and Debian, do not run apache2 -t directly: without the variables from envvars it fails with AH00111: Config variable ${APACHE_RUN_DIR} is not defined. apache2ctl loads them for you.

The most commonly used configuration directives

  • Listen: the port, or address and port, Apache accepts connections on. Listen 80 means every address; Listen 192.0.2.10:8080 only one. It is in httpd.conf on the RHEL family and in ports.conf on Debian and Ubuntu.
  • ServerName: the host name of the server or of a virtual host, for example ServerName www.example.com. Without a global one, configtest warns AH00558: Could not reliably determine the server's fully qualified domain name. Set the global one to the server's own host name (such as server1.example.com), not to a website's name: in our Ubuntu test, a global ServerName www.example.com made the default site answer for www.example.com instead of the real virtual host.
  • ServerRoot: the folder that relative paths start from, /etc/httpd or /etc/apache2. You rarely change it.
  • DocumentRoot: the folder a site is served from, without a trailing slash. If it does not exist, configtest prints AH00112: Warning: DocumentRoot [...] does not exist.
  • <Directory> with Require: who may read a folder. Apache 2.4 uses Require all granted, Require all denied or Require ip 192.0.2.10.
  • AllowOverride: whether .htaccess files may change settings. The default is None; AllowOverride All inside a <Directory> block allows them.
  • ErrorLog, CustomLog and LogLevel: where errors and requests are logged and how much detail (LogLevel warn is the default). A relative path such as logs/error_log is relative to ServerRoot.
  • Include and IncludeOptional: read more files. IncludeOptional does not fail when nothing matches; it is how conf.d/*.conf and sites-enabled/*.conf are loaded.
  • LoadModule: loads a module on the RHEL family, for example LoadModule rewrite_module modules/mod_rewrite.so. On Debian and Ubuntu use a2enmod rewrite instead. In our tests a fresh AlmaLinux 10 install loaded 93 modules (httpd -M) and Ubuntu 26.04 only 28.
  • User and Group: the account Apache's worker processes run as: apache on the RHEL family, www-data (from envvars) on Debian and Ubuntu.
  • UserDir: serves ~/public_html as http://server/~alice/. AlmaLinux ships it switched off (UserDir disabled in conf.d/userdir.conf); Ubuntu needs a2enmod userdir.
  • Timeout and KeepAlive: Timeout is how long Apache waits for network input and output. It is 60 seconds when not set (AlmaLinux does not set it); Ubuntu's apache2.conf sets Timeout 300. Both keep the defaults KeepAlive On, MaxKeepAliveRequests 100 and KeepAliveTimeout 5.

Order, Allow and Deny are the old syntax

Many old guides use Order deny,allow, Deny from all and Allow from. That is Apache 2.2 syntax. Both distributions still load mod_access_compat, so it works, but according to the Apache documentation these directives are deprecated and mixing them with Require is discouraged. Lab example: this block returned 403 for a request from 127.0.0.1, and 200 after adding 127.0.0.1 to the list:

Alias /admin /var/www/admin
<Directory /var/www/admin>
    Require ip 192.0.2.10
</Directory>

For more access rules see rule-based access control for Apache.

Change a directive safely

  1. Copy the file first: cp /etc/httpd/conf/httpd.conf /root/httpd.conf.bak.
  2. Put your own settings in a new file (/etc/httpd/conf.d/mysite.conf, or a site in /etc/apache2/sites-available/) rather than editing the main file, so package updates do not conflict with your changes.
  3. Test the syntax:
    apachectl configtest      # AlmaLinux, Rocky Linux, RHEL
    apache2ctl configtest     # Debian, Ubuntu
    A good file prints Syntax OK. A typo stops it, with the file and line. Lab example:
    AH00526: Syntax error on line 1 of /etc/httpd/conf.d/zz-typo.conf:
    Invalid command 'DocumentRot', perhaps misspelled or defined by a module not included in the server configuration
  4. Apply it without dropping connections: systemctl reload httpd or systemctl reload apache2. After a2enmod, Ubuntu asks for a restart instead.
  5. Check the error log (/var/log/httpd/error_log or /var/log/apache2/error.log) if the site does not behave as expected.

Related guides

Official documentation: Apache directive index and mod_access_compat.

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Linux server management

hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.

Was this answer helpful?

Still stuck? Open a ticket