How to test Apache configuration without restarting the service
It’s always a good idea to test your newly updated Apache
config file before restarting the service itself. This will help avoid downtime due to Apache
refusing to start due to misconfiguration. You can use apachectl
, httpd
or equivalent binaries as in the examples below;
Different platform might use different binary names such as apache
, apache2
or apache2ctl
-
httpd
# httpd -t AH00112: Warning: DocumentRoot [/var/www/mywebsite] does not exist AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message Syntax OK
-
apachectl
# apachectl configtest AH00112: Warning: DocumentRoot [/var/www/mywebsite] does not exist AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message Syntax OK
What happens is that the programs will try to parse the configuration files without implementing any of your changes. Once you get Syntax OK
at the end of the output and are satisfied with all the warnings (if any), you could confidently restart your Apache
service.