tags:

views:

120

answers:

1

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
You could do that either in Ruby or Bash. You better get your bonus points. :)
John Lockwood
Beautiful, thank you :)
Ryan Bigg
Ok, bonus point awarded (+1)
Tim Post