apachectl configtest: Test Apache Config
apachectl configtest parses the Apache httpd configuration and prints Syntax OK or the exact file and line of the first error.
configtest is the Apache equivalent of nginx -t. Run it before any graceful reload so a broken vhost cannot take the server down.
What it does
apachectl configtest (an alias for apachectl -t, which runs httpd -t) parses httpd.conf and all Included files, checks directive syntax and module availability, and prints "Syntax OK" on success. On failure it prints the file, line number, and reason, and exits non-zero.
Common usage
apachectl configtest
# equivalent short forms
apachectl -t
httpd -t # RHEL/CentOS binary name
apache2ctl configtest # Debian/Ubuntu wrapper nameOptions
| Command / Flag | What it does |
|---|---|
| configtest | Run the config syntax test (alias for -t) |
| -t | Test configuration syntax only |
| -t -D DUMP_VHOSTS | Test and dump the virtual host configuration |
| -t -D DUMP_MODULES | Test and list loaded modules |
| -f <file> | Use an alternate main config file |
In CI
Names differ by distro: httpd on RHEL/CentOS, apache2ctl on Debian/Ubuntu, apachectl in the upstream package. Run the test in the same base image you deploy so module paths match. configtest returns non-zero on error, so it works directly as a pipeline gate.
Common errors in CI
Syntax error on line 42 of /etc/apache2/apache2.conf: Invalid command 'FooBar', perhaps misspelled or defined by a module not included in the server configuration means an unknown directive or a missing LoadModule. AH00526: Syntax error ... means a malformed directive. AH00534: httpd: Configuration error: No MPM loaded appears when no MPM module is enabled. apachectl: command not found means httpd is not installed on the runner.