Apacheの設定ファイルの読み込み順序
Apacheが起動されてまず最初にすることは、 設定ファイル httpd.conf の位置を特定して読み込むこと /usr/local/apache2/bin/apachectl -f /usr/local/apache2/conf/httpd.confのように、実行時に変更することもできる。
httpd.confの場所の特定
httpd.confの場所はApacheをビルドする際に決定されている。 -Vオプションで確認することができる。
code:httpd -V
Server version: Apache/2.4.37 (centos)
Server built: Nov 4 2020 03:20:37
Server's Module Magic Number: 20120211:83
Server loaded: APR 1.6.3, APR-UTIL 1.6.1
Compiled using: APR 1.6.3, APR-UTIL 1.6.1
Architecture: 64-bit
Server MPM: event
threaded: yes (fixed thread count)
forked: yes (variable process count)
Server compiled with....
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=256
-D HTTPD_ROOT="/etc/httpd"
-D SUEXEC_BIN="/usr/sbin/suexec"
-D DEFAULT_PIDLOG="run/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
table:CentOS 8のhttpdでの設定ファイルの場所
HTTPD_ROOT /etc/httpd
SERVER_CONFIG_FILE conf/httpd.conf
コンパイル時に組み込まれたモジュールの一覧
-l Output a list of modules compiled into the server. This will not list dynamically loaded modules included using the LoadModule directive.
code:httpd -l
Compiled in modules:
core.c
mod_so.c
http_core.c
ディレクティブの一覧
-L Output a list of directives provided by static modules, together with expected arguments and places where the directive is valid. Directives provided by shared modules are not listed.
code:httpd -L | grep -E '^A-Za-z.+' | wc 497 994 14962
共有オブジェクトとしてロードされたものも含むモジュールの一覧
-M Dump a list of loaded Static and Shared Modules.
code:httpd -M | wc
93 186 2482
$ httpd -t -D DUMP_MODULES
と同じ。
バーチャルホストの設定
メインの設定はこのオプションでは表示されない。
-S Show the settings as parsed from the config file (currently only shows the virtualhost settings).
code: httpd -S
VirtualHost configuration:
*:443 www.example.com (/etc/httpd/conf.d/ssl.conf:40)
ServerRoot: "/etc/httpd"
Main DocumentRoot: "/home/www/wp"
Main ErrorLog: "/home/www/logs/error_log"
Mutex authn-socache: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/etc/httpd/run/" mechanism=default
Mutex cache-socache: using_defaults
Mutex authdigest-opaque: using_defaults
Mutex watchdog-callback: using_defaults
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex authdigest-client: using_defaults
Mutex lua-ivm-shm: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
PidFile: "/etc/httpd/run/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="apache" id=48
Group: name="apache" id=48
$ httpd -t -D DUMP_VHOSTS
でも取得できる。
設定ファイルで設定された内容の一覧
$ httpd -t -D DUMP_CONFIG | grep -v "#"
設定ファイルのテスト
$ httpd -t
$ apachectl -t