10

Is there a command / tool to generate the computed configuration that Apache httpd is using? I know I can manually go through the httpd.conf and other configuration files, but is there a standard tool to generate a configuration of all included files and sections that apply, for convenience?

Thanks,

James

Edit: I should also have mentioned I'm also using a Windows x-64 version of Apache, from a pre-built binary.

2
  • 1
    +1 for great question! I've been administering Apache for more than ten years and only now I realized I have always glimpsed through configuration files instead of the kind of view you are asking for. It sure would be nice to have a view similar to phpinfo() in PHP. :-) Jun 14, 2011 at 9:23
  • @Janne thanks :) I've used Maven before on Java projects as a build tool, which uses various 'POM' XML files for configuration (in various folders) and has a way to do such a thing - view all combined files as one generated POM. I think such a tool is invaluable when trying to sort out configuration Jun 14, 2011 at 10:19

2 Answers 2

5

There is an Apache module available which shows a detailled page with various settings and the active configuration.

mod_info is disabled by default and must be enabled with ./configure --enable-info when building Apache. On Debian and Ubuntu, this module and its configuration can be enabled using sudo a2enmod info.

Put the next lines in your configuration file (httpd.conf) (not necessary when using a2enmod):

<Location /server-info>
    SetHandler server-info
</Location>

After restarting the server, the configuration file is available at http://example.com/server-info?config (replace example.com with your server address)

Note that this information is quite sensitive, you might want to restrict access as in:

<Location /server-info>
  SetHandler server-info
  Order deny,allow
  Deny from all
  Allow from yourcompany.com
</Location>

For more information, see http://httpd.apache.org/docs/2.2/mod/mod_info.html

2
  • Thanks for your suggestion. I guess it is one way of doing it, but I'm looking for a more offline solution - especially with the access control concerns. I think I'd also suggest using some random path instead of /server-info just in case :) Jun 14, 2011 at 10:22
  • /server-info is the default path, hence I'm using it to avoid confusion. Security-wise, you would indeed use a different path with strict access control and disable it after you're done. You could set up Basic/Digest authentication, restrict access to localhost and use curl combined with html2text to get the data in a script.
    – Lekensteyn
    Jun 14, 2011 at 10:35
0

With mod_info enabled:

apache2ctl -DDUMP_CONFIG|grep -vE "^[ ]*#[ ]*"

source: https://stackoverflow.com/a/51585410/936512

OR try: https://serverfault.com/a/743425/166429 (I have not tried this myself)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .