如何列出 Linux 服务器上当前启用的所有 apache2 模块
问题:
如何使用 Apache2 Web 服务器列出当前启用的所有模块?
回答 :
使用 apache2ctl 命令与 -M 组合,您可以列出系统上所有已加载的 apache 模块。例如,以下 linux 命令将在单独的行中列出所有已加载的模块:
# apache2ctl -M
Loaded Modules:
core_module (static)
so_module (static)
watchdog_module (static)
http_module (static)
log_config_module (static)
logio_module (static)
version_module (static)
unixd_module (static)
access_compat_module (shared)
alias_module (shared)
auth_basic_module (shared)
authn_core_module (shared)
authn_file_module (shared)
authz_core_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
deflate_module (shared)
dir_module (shared)
env_module (shared)
filter_module (shared)
geoip_module (shared)
mime_module (shared)
mpm_event_module (shared)
negotiation_module (shared)
rewrite_module (shared)
setenvif_module (shared)
status_module (shared)
上述命令的另一个替代方法是:
# apache2ctl -t -D DUMP_MODULES
另一种但不太可靠的替代方法是列出 /etc/apache2/mods-enabled/ 中所有启用的模块
# ls /etc/apache2/mods-enabled/
access_compat.load auth_basic.load authz_core.load autoindex.conf deflate.load env.load geoip.load mpm_event.conf negotiation.load setenvif.load
alias.conf authn_core.load authz_host.load autoindex.load dir.conf filter.load mime.conf mpm_event.load rewrite.load status.conf
alias.load authn_file.load authz_user.load deflate.conf dir.load geoip.conf mime.load negotiation.conf setenvif.conf status.load
上面列出的所有模块均已启用,但可能尚未加载,因为它们仅代表指向位于 /etc/apache2/mods-available/ 中的对应模块的符号链接。例如:
# ls -l /etc/apache2/mods-enabled/rewrite.load
lrwxrwxrwx. 1 root root 30 Jun 23 02:32 /etc/apache2/mods-enabled/rewrite.load -> ../mods-available/rewrite.load
如果您正在搜索特定的加载模块,只需将 STDOUT 从 apache2ctl 命令重定向到 grep 命令即可。例如,让我们搜索当前是否加载了 rewrite 和 alias 模块:
# apache2ctl -M | grep -E "rewrite|alias"
alias_module (shared)
rewrite_module (shared)
从上面的输出我们可以看到 rewrite 和 alias apache 模块都已加载。
