Apache refuses to start: DefaultRuntimeDir must be a valid directory
Syntax error on line 80 of /etc/apache2/apache2.conf:Short answer
DefaultRuntimeDir is where Apache creates run-time files such as shared memory and locks. The error means the path it resolved is not an existing directory. A relative path is resolved against ServerRoot, so check ServerRoot and the folder, then set DefaultRuntimeDir to a directory that exists.
Fix it fast
1Find out which cause you have
Find every place the directive and ServerRoot are set, and note the exact paths.
grep -rn "DefaultRuntimeDir\|ServerRoot" /etc/apache2/2Match what you see, then jump to its fix
What does the error look like?
Syntax error on line 80 of /etc/apache2/apache2.conf:DefaultRuntimeDir must be a valid directory, absolute or relative to ServerRoot
Cause 1 of 2
The directory does not exist
1Check
Apache writes its run-time files into this directory, so it has to exist. Look for it.
ls -ld /var/run/apache22Fix
Create the directory, or change DefaultRuntimeDir to one that exists.
sudo mkdir -p /var/run/apache2
# or in apache2.conf
DefaultRuntimeDir /var/run/apache23Verify
Start Apache and read the status.
sudo systemctl start apache2 && systemctl status apache2 --no-pagerConfirmed by httpd.apache.org
Cause 2 of 2
A relative path is resolved against the wrong ServerRoot
1Check
The directive docs say a relative path is taken from ServerRoot, and that ServerRoot should be set before DefaultRuntimeDir, otherwise the default ServerRoot is used.
grep -n "ServerRoot\|DefaultRuntimeDir" /etc/apache2/apache2.conf2Fix
Use an absolute path, or put the ServerRoot line above the DefaultRuntimeDir line.
ServerRoot "/etc/apache2"
DefaultRuntimeDir /var/run/apache23Verify
Start Apache again.
sudo systemctl restart apache2Confirmed by httpd.apache.org
How do I stop it coming back?
- Prefer absolute paths for run-time directories.
- Keep ServerRoot at the top of the main config file.
- When you move the runtime folder, update the directive in the same change.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Related fixes
Servers
dnf cannot install MySQL on Amazon Linux 2023
dnf cannot find a mysql-server package on Amazon Linux 2023
Amazon Linux 2023 documents MariaDB, not MySQL, as its database server, with packages named mariadb105 and mariadb105-server.
3 causes, each with a fixServers
Ansible hangs, then times out waiting for the sudo prompt
a playbook using become seems to hang
Ansible ran sudo on the target and never saw the answer it expected.
3 causes, each with a fixServers
Apache on Ubuntu returns 404 Not Found for my site
The requested URL was not found on this server.
On Ubuntu a 404 from Apache usually means the request maps to a path that has no file.
3 causes, each with a fixServers
Apache returns 504 Gateway Timeout when PHP takes too long
Quick requests work, slow ones end in a 504 after a fixed wait
A 504 from Apache means the backend did not answer within the proxy timeout.
2 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fixServers
Apache warns that a ${VAR} config variable is not defined
${VAR} left unchanged in the configuration, with a warning in the error log
Apache expands ${VAR} from Define or from the shell environment that exists when the server starts.
3 causes, each with a fix