I'm looking for a way to programatically detect the location of the Apache config directory, and the name of the configuration file. Bonus points if this is in Ruby or Bash.
+4
A:
Location and name of the config file is determined during compilation, so if you look at compilation settings you will be able to determine it
apachectl -V
will show you a line like this
-D SERVER_CONFIG_FILE="/private/etc/apache2/httpd.conf"
so in ruby you can extract it with something like this:
IO.popen('apachectl -V').read.match(/SERVER_CONFIG_FILE="(.*)"/)[1]
dimus
2009-08-31 02:07:43
You could do that either in Ruby or Bash. You better get your bonus points. :)
John Lockwood
2009-08-31 02:09:58
Beautiful, thank you :)
Ryan Bigg
2009-08-31 03:14:20
Ok, bonus point awarded (+1)
Tim Post
2009-11-02 17:35:13