Sometimes we need to check whether the syntax of the configuration changes which we made is correct or not. Apache web server supports special syntax checking which you can run for the Apache configuration file i.e. httpd.conf file.
Use the below command to check the syntax error in the apache binary program httpd in RHEL.
# httpd -t
* -t : run syntax check for config files
If the syntax is correct then it will return the below output
[root@testserver ~]# httpd -t Syntax OK
If the syntax is not correct then it will return the error with the line number
I have changed the DocumentRoot path to a directory which does not exist and the syntax checker gives the below error.
[root@testserver ~]# httpd -t Syntax error on line 306 of /etc/httpd/conf/httpd.conf: DocumentRoot must be a directory