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 (theServerRootis/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:LoadModulelines for the modules./etc/httpd/logs,modulesandrun: links to/var/log/httpd,/usr/lib64/httpd/modulesand/run/httpd./var/www/html: the default document root. Apache runs as the userapache.
Apache server files on Debian and Ubuntu
/etc/apache2/apache2.conf: the main file.ports.confholds theListenlines.sites-available/andsites-enabled/: virtual hosts. Enable one witha2ensite, disable it witha2dissite.mods-available/andmods-enabled/: modules, switched witha2enmodanda2dismod.conf-available/andconf-enabled/: global snippets, switched witha2enconfanda2disconf./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 80means every address;Listen 192.0.2.10:8080only one. It is inhttpd.confon the RHEL family and inports.confon 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,configtestwarnsAH00558: Could not reliably determine the server's fully qualified domain name. Set the global one to the server's own host name (such asserver1.example.com), not to a website's name: in our Ubuntu test, a globalServerName www.example.commade the default site answer for www.example.com instead of the real virtual host. - ServerRoot: the folder that relative paths start from,
/etc/httpdor/etc/apache2. You rarely change it. - DocumentRoot: the folder a site is served from, without a trailing slash. If it does not exist,
configtestprintsAH00112: Warning: DocumentRoot [...] does not exist. - <Directory> with Require: who may read a folder. Apache 2.4 uses
Require all granted,Require all deniedorRequire ip 192.0.2.10. - AllowOverride: whether
.htaccessfiles may change settings. The default isNone;AllowOverride Allinside a<Directory>block allows them. - ErrorLog, CustomLog and LogLevel: where errors and requests are logged and how much detail (
LogLevel warnis the default). A relative path such aslogs/error_logis relative toServerRoot. - Include and IncludeOptional: read more files.
IncludeOptionaldoes not fail when nothing matches; it is howconf.d/*.confandsites-enabled/*.confare loaded. - LoadModule: loads a module on the RHEL family, for example
LoadModule rewrite_module modules/mod_rewrite.so. On Debian and Ubuntu usea2enmod rewriteinstead. 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:
apacheon the RHEL family,www-data(fromenvvars) on Debian and Ubuntu. - UserDir: serves
~/public_htmlashttp://server/~alice/. AlmaLinux ships it switched off (UserDir disabledinconf.d/userdir.conf); Ubuntu needsa2enmod userdir. - Timeout and KeepAlive:
Timeoutis how long Apache waits for network input and output. It is 60 seconds when not set (AlmaLinux does not set it); Ubuntu'sapache2.confsetsTimeout 300. Both keep the defaultsKeepAlive On,MaxKeepAliveRequests 100andKeepAliveTimeout 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
- Copy the file first:
cp /etc/httpd/conf/httpd.conf /root/httpd.conf.bak. - 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. - Test the syntax:
apachectl configtest # AlmaLinux, Rocky Linux, RHEL apache2ctl configtest # Debian, Ubuntu
A good file printsSyntax 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
- Apply it without dropping connections:
systemctl reload httpdorsystemctl reload apache2. Aftera2enmod, Ubuntu asks for a restart instead. - Check the error log (
/var/log/httpd/error_logor/var/log/apache2/error.log) if the site does not behave as expected.
Related guides
- Apache Web Server on Linux: Install It and Host a Website
- Basic Apache Configuration on Linux (Virtual Hosts, Files and Logs)
- Apache HTTP server: most commonly used containers such as <VirtualHost> and <Directory>
- What Is .htaccess and How to Edit It in cPanel
- How to Start, Stop, or Restart Apache
Official documentation: Apache directive index and mod_access_compat.