Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux技術

用 Apache 控制指令檢查模組是否已啟用或載入

本文簡要說明如何列出或查看已啟用的 Apache 模組。Apache 基於模組化理念建構,管理員可加入不同模組來擴展功能與效能。常見模組有:mod_ssl(HTTPS)、mod_rewrite(正則匹配 URL 與透明轉發)、mod_security(防暴力破解與 DDoS)、mod_status(監測負載與頁面統計)。

在 Linux 中,

apachectl
或
apache2ctl
是控制 Apache 的前端工具。可先查看使用資訊:

$ apache2ctl help   或   $ apachectl help
Usage: /usr/sbin/httpd [-D name] [-d directory] [-f file] [-C "directive"]
 [-c "directive"] [-k start|restart|graceful|graceful-stop|stop]
 [-v] [-V] [-h] [-l] [-L] [-t] [-S]
 -M : a synonym for -t -D DUMP_MODULES
 -t : run syntax check for config files

apache2ctl 可工作在 SysV init 與直通兩種模式。SysV init 模式下以單命令形式操作:

$ sudo apache2ctl start
$ sudo apache2ctl status

直通模式下則可帶入所有 Apache 參數:

$ apachectl [apache-argument]
$ apache2ctl help   # Debian 系
$ httpd help        # RHEL 系

檢查已啟用的模組

-t -D DUMP_MODULES
是能列出所有已啟用模組的參數:

# Debian 系
$ apache2ctl -t -D DUMP_MODULES   或   $ apache2ctl -M
# RHEL 系
$ apachectl -t -D DUMP_MODULES   或   $ httpd -M
[root@tecmint httpd]# apachectl -M
Loaded Modules:
 core_module (static)
 mpm_prefork_module (static)
 auth_basic_module (shared)
 auth_digest_module (shared)
 authn_file_module (shared)
 ...

如此一來,便能輕鬆列出 Apache 已載入的模組了。

Copyright © Linux教程網 All Rights Reserved