I'm looking for a command that checks the validity of the config files in Apache server on both Debian and RHEL distros. I need to do this prior to restart, so there will be no downtime.


Check: http://httpd.apache.org/docs/2.2/programs/apachectl.html

apachectl configtest
  • I am getting this message running the above command AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using Set the 'ServerName' directive globally to suppress this message – Ciasto piekarz Sep 15 '16 at 16:18
  • 2
    Add a line "ServerName whateveryoulike" to your apache config. Replace whateveryoulike with what ever you like to name your server. – Pit Sep 26 '16 at 6:48
  • 2
    might require sudo ? – Miguel Mar 29 '17 at 10:29

Another way is httpd -t. Therefore, it's available in Windows-version of Apache. Check http://httpd.apache.org/docs/2.4/programs/httpd.html

  • 1
    Oddly, on Ubuntu, when I run apachectl configtest I get Syntax OK, but when I run apache2 -t I get AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf (among other errors) – Buttle Butkus Dec 8 '18 at 2:02

apachectl configtest is the correct answer. Unfortunately I've got a windows installation where apachectl is missing. Here calling httpd also helps.


The Apache config test (apachectl configtest, or its equivalents) only tests the config file (and the files it recursively includes) for valid syntax. However, the original question asked for preventing downtime. Even when apachectl configtest does not return an error, an actual restart may still fail, causing downtime.

Common causes for such failures include missing or inaccessible SSL certificates, missing directories for log files or a missing website root directory. Often, such errors are caused by removing a vhost's directory without removing the vhost Apache config file. It is highly recommended to use a tool like puppet or ansible to prevent such inconsistencies.

Seeing that this question is the number one hit when googling "apache config lint" I thought I'd mention this little detail...

  • Is there a way to test for common causes of failure per above? – Vishal Sep 22 '20 at 0:59
  • That would require a script, that parses the apache config and implements the missing checks. I'm not aware of any freely available scripts that does so. – BertD Sep 22 '20 at 12:26

What I usually do is

apache2ctl -t && apache2ctl graceful

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.