Although large amount of alternative web servers a lot of the web services out there still use Apache httpd software.
I will not go into why choose Apache httpd and how, but I like to share a small issue I had with configuration check of my service.
As IT personnel who worked in a production environment I’ve learned the best practice of any configuration change is check your configuration before reloading/restarting the service.
Now Apache httpd configuration check is easy:
1 2 3
# apachectrl configtest ---- or ---- # apachectrl -t
Now – What about when you have multiple apache httpd instances running on the same server?
Every one of them running with it’s own configuration file.
How would you test them?
The solution should have been simple enough – just direct the check for the configuration file!
The issue with that is the relative selection of file won’t work.
Lets see a small example:
1 2 3 4 5 6
---- Following test will result in checking of /etc/httpd/conf/httpd.conf instead of what you wanted ---- /etc/httpd-site/# apachectrl -t -f conf/httpd.conf Syntax OK ---- Following test will fail because he is looking for /etc/http/../conf/httpd.conf ---- /etc/httpd-site/conf.d/# apachectrl -t -f ../conf/httpd.conf httpd: Could not open configuration file /etc/conf/httpd.conf: No such file or directory
So how can you fix that?
1 2 3 4 5 6
---- Use full path ---- /etc/httpd-site/# apachectrl -t -f /etc/httpd-site/conf/httpd.conf Syntax OK ---- Set the work dir for the relative search ---- /etc/httpd-site/# apachectrl -t -d /etc/httpd-site -f conf/httpd.conf Syntax OK
Easy and simple.