如何找出运行时正在使用哪个httpd.conf


29

我一直在努力寻找这一点:您如何询问apache用来加载哪个httpd.conf文件?

当您有许多apache实例在运行,或者很长一段时间没有看计算机时,并且磁盘上有很多httpd.conf文件,这将变得很困难!

非常感谢 :)

Answers:


44
apache2ctl -V | grep SERVER_CONFIG_FILE

答对了。请注意,对于不同的发行版或操作系统,二进制文件可能称为apachectl。同样,HTTPD_ROOT的grep-SERVER_CONFIG_FILE前面的HTTPD_ROOT值将为您提供配置文件的完整路径。
MihaiLimbăşan,2009年

1
就我而言,它是:-D HTTPD_ROOT =“ / srv / www” -D SERVER_CONFIG_FILE =“ / etc / apache2 / httpd.conf”
vartec,2009年

这节省了我的时间=)您还可以httpd.conf在SERVER_CONFIG_FILE命名为其他名称的情况下简单地尝试一下apachectl -V | grep httpd.conf
Cyclonecode

2
也可能是httpd -V
Lotus

对我来说,答案很好,但是我不得不用apachectl代替apache2ctl。
skiabox


2

在优胜美地,我发现是 /Library/Server/Web/Config/apache2/httpd_server_app.conf

即使 apachectl -V | grep .conf

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


0

从2016年起(Bug 59376),Apache 2.4.23从此以后,就可以使用专用于此目的的选项。

它可以显示整个配置文件树,包括行号,这对于调试复杂的配置非常有用。

$ 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

要么,

$ httpd -t -D DUMP_INCLUDES
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.