39

I've always struggled to find this: How can you ask apache which httpd.conf file it used to load up?

It becomes difficult when you have a number of instances of apache running, or if you haven't looked at the machine for a long time, and there are a lot of httpd.conf file on disk!

Thanks a lot :)

0

5 Answers 5

58
apache2ctl -V | grep SERVER_CONFIG_FILE
5
  • 2
    Bingo. Please note that the binary might be called apachectl for different distributions or operating systems. Also grep for HTTPD_ROOT - the value of HTTPD_ROOT prepended to SERVER_CONFIG_FILE will give you the full path to the config file. May 27, 2009 at 15:13
  • 1
    In my case it's: -D HTTPD_ROOT="/srv/www" -D SERVER_CONFIG_FILE="/etc/apache2/httpd.conf"
    – vartec
    May 27, 2009 at 15:26
  • This saved my day=) You could also simply try httpd.conf in the case that the SERVER_CONFIG_FILE is named something else: apachectl -V | grep httpd.conf. Aug 9, 2012 at 14:12
  • 4
    Might also be httpd -V
    – Lotus
    Oct 9, 2014 at 19:57
  • For me the answer worked fine but I had to replace apache2ctl with apachectl.
    – skiabox
    Oct 16, 2018 at 10:38
4

/usr/sbin/apache2 -V provides this info and a little more :)

1
  • You could improve this answer by providing some example output of that command.
    – Ladadadada
    Nov 6, 2014 at 12:57
3

As of 2016 (Bug 59376), from Apache 2.4.23 onwards, an option dedicated to this purpose is available.

It can display the entire config file tree, including line numbers, which is useful to debug complex configurations.

$ apachectl -t -D DUMP_INCLUDES

Included configuration files:
  (*) /etc/httpd/conf/httpd.conf
    (21) /etc/httpd/conf.d/elasticbeanstalk_log.conf
    (21) /etc/httpd/conf.d/healthd.conf
    (21) /etc/httpd/conf.d/ssl.conf
    (22) /etc/httpd/conf.d/elasticbeanstalk/00_application.conf
    (22) /etc/httpd/conf.d/elasticbeanstalk/01_gzip.conf
    (22) /etc/httpd/conf.d/elasticbeanstalk/02_static.conf

Or,

$ httpd -t -D DUMP_INCLUDES
2

In Yosemite I found it was /Library/Server/Web/Config/apache2/httpd_server_app.conf

Even though apachectl -V | grep .conf

Gives -D SERVER_CONFIG_FILE="/private/etc/apache2/httpd.conf"

1
  • Passing arguments to httpd using apachectl is no longer supported.
    – Wang
    Feb 22, 2021 at 21:52
0

For RHEL or Centos, first find the running Apache process...

ps ax | grep httpd

Note the path in the output. For me, it is...

/opt/rh/httpd24/root/usr/sbin/httpd

You can then use the -V option with this path to get the configuration path...

/opt/rh/httpd24/root/usr/sbin/httpd -V

Amongst the output you should see an absolute path for HTTPD_ROOT and also a relative path for the SERVER_CONFIG_FILE. Put that absolute path and relative path together and you have your configuration file location.

Credit: https://stackoverflow.com/a/22900993/861826

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy