Test configuration before restarting Apache

Have you ever made a lot of changes to your apache conf files on your web server that you were worried that the changes may result in apache not restarting? I know I have. There is a way to check your changes before you restart the running service.

cmd:

httpd -t
# or
/usr/sbin/httpd -t

If everything was entered correctly, you should see the following message printed: “Syntax OK”.

If there are errors, it will print the first one it finds and exits. Otherwise it will print all the warnings if any and then print the “Syntax OK” message.

If you keep each virtual host in a separate configuration files like I do, then you can check the specific httpd.conf file.

cmd:

httpd -t -f /path/to/virtual/httpd.conf

Leave a Reply

Your email address will not be published. Required fields are marked *