httpdを直接実行する
備忘録的に。
apachectlを使わないで直接httpdを実行する場合のオプションをメモすることにします。
Apacheは「/usr/local/apache」にインストールされていると仮定ということで。
起動/停止など
結局apachectlの中でも同じことをやっているわけですが。
-
- 起動する
# /usr/local/apache/bin/httpd -k start
-
- 停止する
# /usr/local/apache/bin/httpd -k stop
-
- 再起動
# /usr/local/apache/bin/httpd -k restart
「stop」「restart」だと強制的にプロセスを止めるはずなので、
もう少し安全に止めたかったら、緩やかな再起動になる「graceful」「graceful-stop」が良いですね。
「graceful-stop」はApache2.2以降。
設定ファイルを指定する
上述の「-k」オプションと合わせれば、一時的にコンフィグを指定することも可能。
設定を試すときなんかはいいと思います。
# /usr/local/apache/bin/httpd -k start -f /home/myuser/httpd.conf.tmp
止めるときは、「-f」オプションを忘れずに。
# /usr/local/apache/bin/httpd -k stop -f /home/myuser/httpd.conf.tmp
バージョンを確認する
「-v」で簡易表示。
# /usr/local/apache/bin/httpd -v Server version: Apache/2.2.15 (Unix) Server built: Apr 19 2010 17:03:13
「-V」だともう少し詳細になります。
# /usr/local/apache/bin/httpd -V Server version: Apache/2.2.15 (Unix) Server built: Apr 19 2010 17:03:13 Server's Module Magic Number: 20051115:24 Server loaded: APR 1.4.2, APR-Util 1.3.9 Compiled using: APR 1.4.2, APR-Util 1.3.9 Architecture: 32-bit Server MPM: Worker threaded: yes (fixed thread count) forked: yes (variable process count) Server compiled with.... -D APACHE_MPM_DIR="server/mpm/worker" -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=128 -D HTTPD_ROOT="/usr/local/apache" -D SUEXEC_BIN="/usr/local/apache/bin/suexec" -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"
モジュールの表示
「-l」オプションで静的に組み込まれているモジュールを表示します。
# /usr/local/apache/bin/httpd -l Compiled in modules: core.c mod_authn_file.c mod_authn_default.c mod_authz_host.c mod_authz_groupfile.c mod_authz_user.c mod_authz_default.c mod_auth_basic.c mod_include.c mod_filter.c mod_log_config.c mod_env.c mod_setenvif.c mod_version.c worker.c http_core.c mod_mime.c mod_status.c mod_autoindex.c mod_asis.c mod_cgid.c mod_negotiation.c mod_dir.c mod_actions.c mod_userdir.c mod_alias.c mod_rewrite.c mod_so.c
「-M」で現在ロードされているモジュール一覧を表示します。
Apache2.2以降で使用可能です。
# /usr/local/apache/bin/httpd -M Loaded Modules: core_module (static) authn_file_module (static) authn_default_module (static) authz_host_module (static) authz_groupfile_module (static) authz_user_module (static) authz_default_module (static) auth_basic_module (static) include_module (static) filter_module (static) log_config_module (static) env_module (static) setenvif_module (static) version_module (static) mpm_worker_module (static) http_module (static) mime_module (static) status_module (static) autoindex_module (static) asis_module (static) cgid_module (static) negotiation_module (static) dir_module (static) actions_module (static) userdir_module (static) alias_module (static) rewrite_module (static) so_module (static) Syntax OK
「LoadModule」で組み込んでいるモジュールの場合、以下のように出力されます。
proxy_module (shared) proxy_balancer_module (shared) proxy_http_module (shared) proxy_connect_module (shared)
バーチャルホスト設定の確認
「-S」オプションで「httpd.conf」に定義されているバーチャルホストの設定状況を一覧表示できます。
# /usr/local/apache/bin/httpd -S VirtualHost configuration: xxx.xxx.xxx.10:80 is a NameVirtualHost default server www.example.com (/usr/local/apache/conf/httpd.conf:271) port 80 namevhost www.example.com (/usr/local/apache/conf/httpd.conf:271) Syntax OK