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.
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
Another way is
httpd -t
. Therefore, it's available in Windows-version of Apache. Check http://httpd.apache.org/docs/2.4/programs/httpd.htmlThe 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 whenapachectl 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...
apachectl configtest
is the correct answer. Unfortunately I've got a windows installation where apachectl is missing. Here callinghttpd
also helps.What I usually do is
I have actually tried before:
We can actually see the status code to know the error: