40

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 :)

5 Answers5

58
apache2ctl -V | grep SERVER_CONFIG_FILE
vartec
  • 6,137
  • 2
  • 32
  • 49
  • 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. – Mihai Limbăşan May 27 '09 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 '09 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`. – Cyclonecode Aug 09 '12 at 14:12
  • 4
    Might also be httpd -V – Lotus Oct 09 '14 at 19:57
  • For me the answer worked fine but I had to replace apache2ctl with apachectl. – skiabox Oct 16 '18 at 10:38
5

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

Bradley Flood
  • 151
  • 1
  • 3
4

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
Amit Naidu
  • 774
  • 5
  • 11
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"

user281263
  • 21
  • 1
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

arnoldbird
  • 125
  • 5