Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've many domain hosted on my server. A new domain is configured with generic configuration. Usually users does not know and delete folders which are given for documentroot path in apache, sometimes when i restart apache after doing changes i get error those means that the directories does not exist. Is it possible to check the existence of folder which are defined for documentroot in apache and then stop and start the apache

in short i want to check existence of all the folders path which are in httpd.conf before i issue the command /etc/init.d/httpd stop. Any help please

share|improve this question

Execute following before restarting your httpd server so that you can find out whether any DocumentRoot path is missing or not.

for i in `grep DocumentRoot /etc/apache2/* -rh | awk '{ print $2 }' | uniq`
[[ -d $i ]] || echo \"$i\" is not in your system
share|improve this answer
What to do with other directories like Error log and the directory under Directory except Documentroot??? – User4283 Jan 15 '13 at 18:10
$ [ -f "/var/log/apache2/access.log" ] || echo "File not found" $ [ -f "/var/log/apache2/error.log" ] || echo "File not found" – Suku Jan 16 '13 at 1:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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