http コマンド
Apacheの起動以外のオプション紹介。
・シンタックスチェック
$ httpd -t Syntax OK-t オプションを付けて実行する事で設定ファイルのシンタックスチェックが可能です。実行結果に『 Syntax OK 』と表示されれば問題なしです。
・バーチャルホストの設定を一覧表示&シンタックスチェック
$ httpd -S
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server localhost (/etc/httpd/conf/vhosts/00_default.conf:1)
port 80 namevhost localhost (/etc/httpd/conf/vhosts/00_default.conf:1)
port 80 namevhost www1.example.com (/etc/httpd/conf/vhosts/www1.conf:1)
port 80 namevhost www2.example.com (/etc/httpd/conf/vhosts/www2.conf:1)
*:443 is a NameVirtualHost
default server localhost (/etc/httpd/conf/vhosts/00_default_ssl.conf:1)
port 443 namevhost localhost (/etc/httpd/conf/vhosts/00_default_ssl.conf:1)
Syntax OK
読み込まれるバーチャルホストの設定を一覧表示した上でシンタックスチェックしてくれます。バーチャルホストの追加を行う際、正常に読み込まれているか確認するのにとても有用です。
・読み込まれるモジュールを一覧表示&シンタックスチェック
$ httpd -M Loaded Modules: core_module (static) mpm_prefork_module (static) http_module (static) so_module (static) auth_basic_module (shared) auth_digest_module (shared) authn_file_module (shared) authn_alias_module (shared) Syntax OK読み込まれるモジュールを一覧表示した上でシンタックスチェックしてくれます。あまり使用頻度は高くありませんが、サードパーティーのモジュールを読み込ませたり、何かが動かない時のトラブルシューティングに使えます。
・設定項目の名前と簡単な解説、記述が可能かを一覧表示
$ httpd -L
<Directory (core.c)
Container for directives affecting resources located in the specified directories
Allowed in *.conf only outside <Directory>, <Files> or <Location>
<Location (core.c)
Container for directives affecting resources accessed through the specified URL paths
Allowed in *.conf only outside <Directory>, <Files> or <Location>
<VirtualHost (core.c)
Container to map directives to a particular virtual host, takes one or more host addresses
Allowed in *.conf only outside <Directory>, <Files> or <Location>
<Files (core.c)
Container for directives affecting files matching specified patterns
Allowed in *.conf anywhere and in .htaccess
when AllowOverride isn't None
<Limit (core.c)
Container for authentication directives when accessed using specified HTTP methods
Allowed in *.conf anywhere and in .htaccess
when AllowOverride isn't None
Apache 設定ファイルのディレクティブ(設定項目)の名前と簡単な解説、設定ファイルのどこに記述が可能かを一覧表示してくれます。『 KeepAlive の設定を追加したいけど、どこに書けばいいんだっけ?』というような時にちゃちゃっと調べられます。
・Apache の詳細な情報一覧
$ httpd -V
Server version: Apache/2.2.3
Server built: Sep 3 2009 17:38:51
Server's Module Magic Number: 20051115:3
Server loaded: APR 1.2.7, APR-Util 1.2.7
Compiled using: APR 1.2.7, APR-Util 1.2.7
Architecture: 32-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-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="/etc/httpd"
-D SUEXEC_BIN="/usr/sbin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
Apache のバージョン情報を表示してくれます。大文字の V はより詳細な情報( APR ライブラリのバージョンや MPM 、コンパイル時の条件等)を表示してくれます。apachectl や apche2ctl といったコマンドもありますが、これは httpd コマンドの wrapper 的なもので、中身を見てみると大体ただのシェルスクリプトだったりします。ディストリビューションによって使い方がまちまちで覚えるのが面倒なので、httpd コマンドを直接使ったほうがいいです。
TOP
Apache セキュリティ対策設定
Apache(XAMPP含む)セキュリティについてのエトセトラ
・ディレクトリリスティング(conf\httpd.conf)
[修正前] Options Indexes FollowSymLinks Includes ExecCGI [修正後] Options FollowSymLinks Includes ExecCGI設定の中の『 Indexes 』の記述があるとindex.htmlファイルが配置されなかった場合、配下のファイルやディレクトリの一覧を表示してしまい不本意な情報を与えてしまうので、記述を削除することによってNotFound等のエラーを返します。
・HTTPバナー、サーバー情報隠ぺい(conf\httpd.conf, conf\extra\httpd-default.conf)
[修正前] ServerTokens Full ServerSignature On [修正後] ServerTokens Prod ServerSignature Off403、404などなどのエラー画面、HTTPヘッダー情報にバージョンなどの情報が表示されますが、その表示にある程度規制をかけることができます。
TOP
mysql コマンド
MySQLの設定方法など。
・データベースの場所を調べる
$ mysql -u root -p mysql> show variables like 'datadir'; +---------------+-----------------------+ | Variable_name | Value | +---------------+-----------------------+ | datadir | /var/lib/mysql/ | +---------------+-----------------------+ 1 row in set (0.00 sec)
・データベースのディレクトリ変更
[/etc/mysql/my.cnf] : datadir = /var/lib/mysql
・データベース設定値の詳細確認
TOP$ mysql -u root -p mysql> show variables;