If you’re going to do something crazy like edit your Apache config on your production server without testing it in a test environment it’s important to at least make sure you’re configuration files are formatted correctly.

Apache provides a command line switch to apachectl to do just that:

$ sudo apachectl configtest
Syntax error on line 4 of /etc/apache2/sites-enabled/000-default:
Invalid command 'DaocumentRoot', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.

This way you can make sure you won’t mess stuff up when you reload the service.

$ sudo service apache2 restart
Syntax error on line 4 of /etc/apache2/sites-enabled/000-default:
Invalid command 'DaocumentRoot', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
   ...fail!