Apache’s config syntax has a few gotchas that produce confusing errors — knowing how to test before reloading (and what the common mistakes actually look like) saves real downtime.
# ALWAYS run this before reloading - catches syntax errors before they take the site down sudo apache2ctl configtest # or sudo apachectl -t # Reload only applies changes if the config is valid; # restart is more disruptive and drops existing connections sudo systemctl reload apache2 # preferred - graceful sudo systemctl restart apache2 # only if reload isn't sufficient
Common Syntax Pitfalls
# Missing closing tag - a classic copy-paste error
<VirtualHost *:80>
ServerName example.com
# </VirtualHost> <- forgot this line entirely
# Mismatched quotes in a directive
DocumentRoot "/var/www/example.com/public
# A directive placed outside its required context
# (e.g. AllowOverride outside a <Directory> block)
Never reload Apache on a production server without running configtest first — a syntax error in the config means Apache refuses to reload at all, potentially leaving the old (possibly also broken) config running, or worse, failing to restart after a crash.