Apache warns that a ${VAR} config variable is not defined
Config variable is not definedShort answer
Apache expands ${VAR} from Define or from the shell environment that exists when the server starts. If the name is in neither, the text stays as written and a warning is logged. Start Apache through apachectl so its envvars file is loaded, or add a Define. SetEnv does not work here.
Fix it fast
1Find out which cause you have
Run the syntax check as your normal service would, and read which variable name Apache complains about.
apachectl -t2Match what you see, then jump to its fix
- 1
The warning names variables you never defined yourself, and it appears only when you run the httpd binary directlyApache was started without its envvars fileFix - 2
The variable exists in the site config, but Apache still logs that it is not defined at startThe variable is set with SetEnv or defined too lateFix - 3
A name in your own config, such as ${MY_APP_ROOT}, is reported and nothing sets it anywhereThe variable name is misspelled or never exportedFix
- 1
What does the error look like?
Config variable is not defined${VAR} left unchanged in the configuration, with a warning in the error log
Cause 1 of 3
Apache was started without its envvars file
1Check
apachectl sets the environment variables Apache needs and then runs httpd. Starting the binary yourself skips that step, so those variables do not exist. Compare the two ways of starting.
apachectl -t
httpd -t2Fix
Start and test through apachectl. If you must run the binary, load the envvars file from your install in the same shell first; the docs show it next to apachectl, and its location depends on how Apache was built or packaged.
apachectl configtest
apachectl restart3Verify
The syntax test passes and no 'is not defined' line appears.
apachectl -tConfirmed by httpd.apache.org
Cause 2 of 3
The variable is set with SetEnv or defined too late
1Check
Only shell environment variables set before the server starts, or Define values, can be used in ${VAR} expansion. SetEnv takes effect too late for that.
grep -rn -E 'SetEnv|Define' /etc/apache2/ /usr/local/apache2/conf/ 2>/dev/null2Fix
Use Define for a value that belongs in the config, and reference it with ${NAME}. Define wins over a shell variable of the same name.
Define DOCROOT /var/www/html
DocumentRoot "${DOCROOT}"3Verify
Test the configuration again.
apachectl -tConfirmed by httpd.apache.org
Cause 3 of 3
The variable name is misspelled or never exported
1Check
When the name is not found, Apache leaves the characters ${VAR} unchanged and logs a warning. Search every place that should set the name.
grep -rn 'MY_APP_ROOT' /etc/apache2/ /usr/local/apache2/conf/ 2>/dev/null2Fix
Correct the spelling, or add a Define (or export the variable in the environment that launches Apache, before it starts).
Define MY_APP_ROOT /srv/my-app3Verify
Run the syntax test and restart.
apachectl -t
apachectl gracefulConfirmed by httpd.apache.org
How do I stop it coming back?
- Always run apachectl -t before a restart.
- Prefer Define over environment variables for values that live in the Apache config.
- In containers, set the environment variable in the image or entrypoint before Apache starts.
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
AH00558: Apache in Docker cannot reliably determine its fully qualified domain name
Set the 'ServerName' directive globally to suppress this message
AH00558 is a warning, not a crash.
2 causes, each with a fixServers
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 fix