有没有办法在解决任何/所有包含内容等之后查看正在运行的 Apache 实例正在使用的最终“有效”配置?
我正在查看一个包含大量内容的配置,怀疑我遇到的一些问题与所有内容的顺序有关。我认为 apachectl 可以验证配置没有语法错误,但我想知道我是否可以更进一步,以某种方式输出完整的配置。有什么建议吗(除了清理这种不应该发生的混乱的包含内容)?
答案1
是的,在一定程度上,但我认为它满足了您的要求。您可以使用mod_info
为了这。
来自在线文档(重点是我的):
启动时转储配置
如果设置了
config
定义,将在服务器启动期间将预解析的配置转储到 stdout。预解析意味着将评估和等指令并替换环境变量。但是,它并不代表配置的最终状态。特别是,-DDUMP_CONFIG
mod_info
<IfDefine>
<IfModule>
它不代表重复指令可能发生的合并或覆盖。这大致相当于
?config
查询。
和:
[...]可以通过在请求中附加查询来查看配置信息
server-info
。例如,http://your.host.example.com/server-info?config
将显示所有配置指令。?配置
仅配置指令,不按模块排序
例如,对于 Fedora 22 中的默认配置,标记为 的行In file
包含在主httpd.conf
文件中:
# curl -v http://localhost/server-info?config | elinks -dump
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying ::1...
* Connected to localhost (::1) port 80 (#0)
> GET /server-info?config HTTP/1.1
> User-Agent: curl/7.40.0
> Host: localhost
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Tue, 02 Jun 2015 20:49:43 GMT
< Server: Apache/2.4.12 (Fedora)
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=ISO-8859-1
<
{ [8014 bytes data]
100 8561 0 8561 0 0 1792k 0 --:--:-- --:--:-- --:--:-- 2090k
* Connection #0 to host localhost left intact
Apache Server Information
Configuration:
In file: /etc/httpd/conf/httpd.conf
42: Listen 80
66: User apache
67: Group apache
86: ServerAdmin root@localhost
102: <Directory />
103: AllowOverride none
104: Require all denied
: </Directory>
119: DocumentRoot "/var/www/html"
124: <Directory "/var/www">
125: AllowOverride None
127: Require all granted
: </Directory>
131: <Directory "/var/www/html">
144: Options Indexes FollowSymLinks
151: AllowOverride None
156: Require all granted
: </Directory>
164: DirectoryIndex index.html
171: <Files ".ht*">
172: Require all denied
: </Files>
182: ErrorLog "logs/error_log"
189: LogLevel warn
196: LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\"
\"%{User-Agent}i\"" combined
197: LogFormat "%h %l %u %t \"%r\" %>s %b" common
201: LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\"
\"%{User-Agent}i\" %I %O" combinedio
217: CustomLog "logs/access_log" combined
247: ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
255: <Directory "/var/www/cgi-bin">
256: AllowOverride None
257: Options None
258: Require all granted
: </Directory>
266: TypesConfig /etc/mime.types
283: AddType application/x-compress .Z
284: AddType application/x-gzip .gz .tgz
305: AddType text/html .shtml
306: AddOutputFilter INCLUDES .shtml
316: AddDefaultCharset UTF-8
324: MIMEMagicFile conf/magic
348: EnableSendfile on
In file: /etc/httpd/conf.d/autoindex.conf
16: IndexOptions FancyIndexing HTMLTable VersionSort
21: Alias /icons/ "/usr/share/httpd/icons/"
23: <Directory "/usr/share/httpd/icons">
24: Options Indexes MultiViews FollowSymlinks
25: AllowOverride None
26: Require all granted
: </Directory>
34: AddIconByEncoding (CMP,/icons/compressed.gif) x-compress
x-gzip
36: AddIconByType (TXT,/icons/text.gif) text/*
37: AddIconByType (IMG,/icons/image2.gif) image/*
38: AddIconByType (SND,/icons/sound2.gif) audio/*
39: AddIconByType (VID,/icons/movie.gif) video/*
41: AddIcon /icons/binary.gif .bin .exe
42: AddIcon /icons/binhex.gif .hqx
43: AddIcon /icons/tar.gif .tar
44: AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
45: AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
46: AddIcon /icons/a.gif .ps .ai .eps
47: AddIcon /icons/layout.gif .html .shtml .htm .pdf
48: AddIcon /icons/text.gif .txt
49: AddIcon /icons/c.gif .c
50: AddIcon /icons/p.gif .pl .py
51: AddIcon /icons/f.gif .for
52: AddIcon /icons/dvi.gif .dvi
53: AddIcon /icons/uuencoded.gif .uu
54: AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
55: AddIcon /icons/tex.gif .tex
56: AddIcon /icons/bomb.gif core.
58: AddIcon /icons/back.gif ..
59: AddIcon /icons/hand.right.gif README
60: AddIcon /icons/folder.gif ^^DIRECTORY^^
61: AddIcon /icons/blank.gif ^^BLANKICON^^
67: DefaultIcon /icons/unknown.gif
85: ReadmeName README.html
86: HeaderName HEADER.html
92: IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
In file: /etc/httpd/conf.d/mod_dnssd.conf
2: DNSSDEnable on
In file: /etc/httpd/conf.d/userdir.conf
17: UserDir disabled
31: <Directory "/home/*/public_html">
32: AllowOverride FileInfo AuthConfig Limit Indexes
33: Options MultiViews Indexes SymLinksIfOwnerMatch
IncludesNoExec
34: Require method GET POST OPTIONS
: </Directory>
In file: /etc/httpd/conf.d/welcome.conf
8: <LocationMatch "^/+$">
9: Options -Indexes
10: ErrorDocument 403 /.noindex.html
: </LocationMatch>
13: <Directory /usr/share/httpd/noindex>
14: AllowOverride None
15: Require all granted
: </Directory>
18: Alias /.noindex.html /usr/share/httpd/noindex/index.html
In file: /etc/httpd/conf/httpd.conf
355: <Location "/server-info">
356: SetHandler server-info
: </Location>