LoginSignup
227

More than 5 years have passed since last update.

メモ:Apacheの設定ファイル(http.conf)を確認する (1)

Posted at

最近、PHPを本格的に勉強しよう!とPHPとMySQLの連携も書いてある本を買って読んでいるのですが、「あれ?そう言えば設定ファイルの中身をよく知らないな...」と今更ながら思ったので、まずはApacheの設定ファイルを確認していこうと思います。

何かの参考になるかもしれないので、共有。
(書く前から分かってはいたけれども、やはり長くなってしまったので分割。)

環境

Mac OS Xに仮想環境で立ち上げた
chef/centos-6.5 | CentOS 6.5 | httpd 2.2.15-30

上記環境の/etc/httpd/conf/httpd.confについて、
Apache HTTP Server Version 2.2 Documentationを見ながら確認し、項目ごとに記載していきます。

※ chef/centos-6.5のBoxにて、yum install httpdしたデフォルト設定ファイルをもとにしています。
すべての設定を確認している訳ではありません。

設定ファイルの中身

1.ServerTokens
HTTP通信において、OS 種別や、コンパイルされて組み込まれているモジュールの情報を返すか指定する。
この設定は全ての環境で適用され、バーチャルホスト上で有効・無効にはできない。

構文
ServerTokens Prod[uctOnly] Apache Server
ServerTokens Major Apache/2 Server
ServerTokens Minor Apache/2.2 Server
ServerTokens Min[imal] Apache/2.2.15 Server
ServerTokens OS Apache/2.2.15 (CentOS) Server
ServerTokens Full (もしくは未指定) Apache/2.2.15 (CentOS) DAV/2 PHP/5.3.3 Server
httpd.conf
#
# Don't give away too much information about all the subcomponents
# we are running.  Comment out this line if you don't mind remote sites
# finding out what major optional modules you are running
ServerTokens OS

2.ServerRoot
Apacheがインストールされているディレクトリを指定する。(ServerRoot directory-path)

httpd.conf
#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE!  If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the LockFile documentation
# (available at <URL:http://httpd.apache.org/docs/2.2/mod/mpm_common.html#lockfile>);
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
ServerRoot "/etc/httpd"

3.PidFile
デーモンのプロセスIDをサーバが記録するファイルを設定する。(PidFile filename)
絶対パスでない場合、ServerRootからの相対的なものとして扱う。

# cat /etc/httpd/run/httpd.pid 
2599
# ps -ef | grep httpd
root      2599     1  0 10:48 ?        00:00:00 /usr/sbin/httpd
httpd.conf
#
# PidFile: The file in which the server should record its process
# identification number when it starts.  Note the PIDFILE variable in
# /etc/sysconfig/httpd must be set appropriately if this location is
# changed.
#
PidFile run/httpd.pid

※ 上記の絶対パスは/etc/httpd/run/httpd.pidとなる。

3.Timeout
リクエストを失敗させるまでにサーバが 待つ時間を設定する。(TimeOut seconds)
以下の三つの待ち時間についての定義:

  • GET リクエストを受け取るのにかかる総時間
  • POST や PUTリクエストにおいて、次の TCP パケットが届くまでの待ち時間
  • レスポンスを返す際、TCP の ACK が帰ってくるまでの時間
httpd.conf
#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 60

4.KeepAlive
HTTP通信の持続的な接続を設定する。(KeepAlive On|Off

httpd.conf
#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive Off

5.MaxKeepAliveRequests
持続的な接続上で許可されるリクエストの数を設定する。(MaxKeepAliveRequests number)
0 に設定していれば、受け付けるリクエストは無制限になる。

httpd.conf
#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

6.KeepAliveTimeout
持続的な接続で次のリクエストが来るまでサーバが待つ時間を設定する。(KeepAliveTimeout seconds)

httpd.conf
#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 15

7.Apache MPM prefork
スレッドを使わず、先行して fork を行なうウェブサーバを実装する。

StartServers:
起動時に生成される子サーバプロセスの数を設定する。(StartServers number)

MinSpareServers:
アイドル中(リクエストを扱っていないプロセス)、子サーバプロセスの最小個数を設定する。(MinSpareServers number)

MaxSpareServers:
アイドル中(リクエストを扱っていないプロセス)、子サーバプロセスの最大個数を設定する。(MaxSpareServers number)

ServerLimit:
設定可能なサーバプロセス数の上限を設定する。(ServerLimit number)
preforkモジュールの場合、 Apacheプロセス稼働中における MaxClientsに設定可能な上限値を設定することになる。

注意1: 必要以上に大きな値に設定された場合は、余計な未使用共有メモリが割り当てられる。
注意2: ServerLimit と MaxClients がシステムの扱える範囲を越えた設定値になっていると、Apacheは起動しないか、起動しても不安定になる。

MaxClients:
応答することのできる同時リクエスト数を設定する。(MaxClients number)

MaxRequestsPerChild:
個々の子サーバプロセスが扱うことのできるリクエストの制限数を設定する。(MaxRequestsPerChild number)

httpd.conf
##
## Server-Pool Size Regulation (MPM specific)
## 

# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# ServerLimit: maximum value for MaxClients for the lifetime of the server
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule prefork.c>
StartServers       8
MinSpareServers    5
MaxSpareServers   20
ServerLimit      256
MaxClients       256
MaxRequestsPerChild  4000
</IfModule>

8.Apache MPM worker
マルチスレッドとマルチプロセスのハイブリッド型ウェブサーバを実装する。

MinSpareThreads:
リクエストに応答するスレッド数の最小値を設定する。(MinSpareThreads number)

MaxSpareThreads:
リクエストに応答するアイドルなスレッドの最大数を設定する。(MaxSpareThreads number)

ThreadsPerChild:
それぞれの子プロセスで生成されるスレッド数を設定する。(ThreadsPerChild number)

# worker MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule worker.c>
StartServers         4
MaxClients         300
MinSpareThreads     25
MaxSpareThreads     75 
ThreadsPerChild     25
MaxRequestsPerChild  0
</IfModule>

9.Listen
サーバが listen するIP アドレスとポート番号を設定する。(Listen [IP-address:]portnumber [protocol])

注意1:IPv6 アドレスは角括弧で囲まなければならない。
Listen [2001:db8::a00:20ff:fea7:ccea]:80
注意2:無指定の場合、443 番ポートにはhttpsが、他のポートにはhttpがデフォルト値として使用される。
非標準なポートで運用している際にのみ protocol 指定が必要になる。
Listen 192.170.2.1:8443 https

httpd.conf
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, in addition to the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to 
# prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
#
#Listen 12.34.56.78:80
Listen 80

10.LoadModule
オブジェクトファイルやライブラリをリンクし、使用モジュールのリストに追加する。(LoadModule module filename)

httpd.conf
#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_alias_module modules/mod_authn_alias.so
LoadModule authn_anon_module modules/mod_authn_anon.so
LoadModule authn_dbm_module modules/mod_authn_dbm.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_owner_module modules/mod_authz_owner.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_dbm_module modules/mod_authz_dbm.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule ldap_module modules/mod_ldap.so
LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
LoadModule include_module modules/mod_include.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule logio_module modules/mod_logio.so
LoadModule env_module modules/mod_env.so
LoadModule ext_filter_module modules/mod_ext_filter.so
LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule expires_module modules/mod_expires.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so
LoadModule usertrack_module modules/mod_usertrack.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule mime_module modules/mod_mime.so
LoadModule dav_module modules/mod_dav.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule info_module modules/mod_info.so
LoadModule dav_fs_module modules/mod_dav_fs.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
LoadModule actions_module modules/mod_actions.so
LoadModule speling_module modules/mod_speling.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
LoadModule substitute_module modules/mod_substitute.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule cache_module modules/mod_cache.so
LoadModule suexec_module modules/mod_suexec.so
LoadModule disk_cache_module modules/mod_disk_cache.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule version_module modules/mod_version.so

#
# The following modules are not loaded by default:
#
#LoadModule asis_module modules/mod_asis.so
#LoadModule authn_dbd_module modules/mod_authn_dbd.so
#LoadModule cern_meta_module modules/mod_cern_meta.so
#LoadModule cgid_module modules/mod_cgid.so
#LoadModule dbd_module modules/mod_dbd.so
#LoadModule dumpio_module modules/mod_dumpio.so
#LoadModule filter_module modules/mod_filter.so
#LoadModule ident_module modules/mod_ident.so
#LoadModule log_forensic_module modules/mod_log_forensic.so
#LoadModule unique_id_module modules/mod_unique_id.so
#

11.Include
サーバ設定ファイル中から他の設定ファイルを取り込む。(Include file-path|directory-path)

httpd.conf
#
# Load config files from the config directory "/etc/httpd/conf.d".
#
Include conf.d/*.conf

12.ExtendedStatus
各リクエストに対して拡張ステータス情報を保存する。(ExtendedStatus On|Off)

httpd.conf
#
# ExtendedStatus controls whether Apache will generate "full" status
# information (ExtendedStatus On) or just basic information (ExtendedStatus
# Off) when the "server-status" handler is called. The default is Off.
#
#ExtendedStatus On

13.User / Group
User:
サーバがリクエストに応答する際に用いるユーザIDを設定する。(User unix-userid)

Group:
リクエストに応答する際に所属するグループを設定する。(Group unix-group)

httpd.conf
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.  
#
# User/Group: The name (or #number) of the user/group to run httpd as.
#  . On SCO (ODT 3) use "User nouser" and "Group nogroup".
#  . On HPUX you may not be able to use shared memory as nobody, and the
#    suggested workaround is to create a user www and use that user.
#  NOTE that some kernels refuse to setgid(Group) or semctl(IPC_SET)
#  when the value of (unsigned)Group is above 60000; 
#  don't use Group #-1 on these systems!
#
User apache
Group apache

14.ServerAdmin
サーバがクライアントに送るエラーメッセージに含める電子メールの アドレスを設定する。(ServerAdmin email-address|URL)

httpd.conf
### Section 2: 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition.  These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#

#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
ServerAdmin root@localhost

15.ServerName
サーバが自分自身を示すときに使うホスト名とポートを設定する。
(ServerName [scheme://]fully-qualified-domain-name[:port])

httpd.conf
#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If this is not set to valid DNS name for your host, server-generated
# redirections will not work.  See also the UseCanonicalName directive.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
# You will have to access it by its address anyway, and this will make 
# redirections work in a sensible way.
#
#ServerName www.example.com:80

16.UseCanonicalName
サーバが自分自身の名前とポートを決定する方法を設定する。(UseCanonicalName On|Off|Dns)

構文 内容
On ServerName で指定されているホスト名とポート番号を使って、その正規名 (自己参照の名前) を生成する。
Off クライアントがホスト名とポートを指定したときには、それらを元に自己参照URLを作成する。
(指定がなかったときは上の定義と同様にして正規名を解決する。)
Dns クライアントが接続したIPアドレスに対してDNSの逆引きを行なって、自己参照URLを作成する。
(大規模なIPベースのバーチャルホスティングで、Host:ヘッダを提供しない古いクライアントをサポートする場合を想定。)
httpd.conf
#
# UseCanonicalName: Determines how Apache constructs self-referencing 
# URLs and the SERVER_NAME and SERVER_PORT variables.
# When set "Off", Apache will use the Hostname and Port supplied
# by the client.  When set "On", Apache will use the value of the
# ServerName directive.
#
UseCanonicalName Off

17.DocumentRoot
ウェブから見えるメインのドキュメントツリーになるディレクトリを設定する。(DocumentRoot directory-path)
注意1:directory-pathが絶対パスでない場合は、ServerRootからの相対パスとみなされる。
注意2:最後のスラッシュ無しで指定する必要がある。

httpd.conf
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/var/www/html"

18.<Directory>
指定のファイルシステムのディレクトリとサブディレクトリにのみ適用される。
(<Directory directory-path> ... </Directory>)
directive-pathは、フルパスもしくはUnixのシェル形式のワイルドカードを指定する。

httpd.conf
#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories). 
#
# First, we configure the "default" to be a very restrictive set of 
# features.  
#
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/var/www/html">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
    Options Indexes FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
    AllowOverride None

#
# Controls who can get stuff from this server.
#
    Order allow,deny
    Allow from all

</Directory>

~ という文字を付加することで正規表現を利用することも可能。
(<Directory ~ "^/www/.*/[0-9]{3}">)

注意1:もし複数の(正規表現以外の)セクションがドキュメントを含むディレクトリ(やその上位ディレクトリのどれか)とマッチしたならば、.htaccessファイルのディレクティブも読み込みつつ、短いパスから順に適用される。

# /home/web/dir/doc.html への アクセス
# AllowOverride None が適用される。 (.htaccess ファイルは無効になる)
<Directory />
AllowOverride None
</Directory>

# (/home ディレクトリに対して)AllowOverride FileInfo が適用される。
# /home/.htaccess, /home/web/.htaccess, /home/web/dir/.htaccess の順に
# それらのファイル中の FileInfo ディレクティブが適用される。
<Directory /home/>
AllowOverride FileInfo
</Directory>

Options:
ディレクトリに対して使用可能な機能を設定する。(Options [+|-]option [[+|-]option] ...)

構文 内容
Options All MultiViews を除いた全ての機能が有効となる。
Options ExecCGI mod_cgi によるCGIスクリプトの実行を許可する。
Options FollowSymLinks このディレクトリ内でシンボリックリンクをたどれるようにする。
Options Includes mod_include が提供するSSIを有効にする。
Options IncludesNOEXEC SSIは有効になるが、#execコマンド と#exec CGIは無効になる。
Options Indexes URLがディレクトリにマップするリクエストであって、
かつDirectoryIndex(後述)で指定したファイルがディレクトリ内に無ければ、
mod_autoindex がディレクトリ内の一覧を整形して返す。
Options MultiViews mod_negotiation によるコンテントネゴシエーションされた "MultiViews" を許可する。
Options SymLinksIfOwnerMatch シンボリック先のファイルまたはディレクトリが、
シンボリックリンクの所有ユーザIDと同じ場合にのみ
シンボリックリンクをたどれるようにする。

AllowOverride:
.htaccess で許可されるディレクティブの種類を設定する。
(AllowOverride All|None|directive-type [directive-type] ...)

構文 内容
AllowOverride All .htaccess というコンテキストを持つ全てのディレクティブが利用できる。
AllowOverride None .htaccess ファイルは完全に無視される。
サーバはファイルシステムの .htaccess ファイルを読むことを試みさえしない。
AllowOverride AuthConfig 認証に関するディレクティブの使用を許可する。
AllowOverride FileInfo ドキュメントタイプの制御、ドキュメントのメタデータの制御、
mod_rewrite、mod_actions のAction の使用を許可する。
AllowOverride Indexes ディレクトリインデックスを制御するためのディレクティブの使用を許可する。
AllowOverride Limit ホストへのアクセス制御を行うためのディレクティブの使用を許可する。
AllowOverride Options[=Option,...] 特定のディレクトリにおける機能を指定するためのディレクティブの使用を許可する。

Order:
デフォルトのアクセス可能な状態と、AllowとDenyが評価される順番を制御する。(Order ordering)

構文 内容
Order Deny,Allow Deny が Allow の前に評価される。
Deny に合わないか、Allow に合うクライアントはアクセスを許可される。
Order Allow,Deny Allow が Deny の前に評価される。
Allow に合わないか、Deny に合うクライアントはアクセスを拒否される。
Order Mutual-failure Allow のリストに現れて、Deny のリストに現れないホストのみがアクセスを許可される。
Order Allow,Deny と同じ効果を持ち、その設定の方が好ましいために非推奨。

Allow:
サーバのある領域にアクセスできるホストを制御する。
(Allow from all|host|env=env-variable [host|env=env-variable] ...)

# ドメイン名 (の一部)
# クライアントの IP アドレスに対して DNS の 2 重逆引きを行う。
# ホスト名からオリジナルのIPアドレスを順引きします。
# 順引きと逆引きが一致し、ホスト名が該当した場合にのみ、アクセスが許可される。
Allow from apache.org
Allow from .net example.edu


# 完全な IP アドレス
Allow from 10.1.2.3
Allow from 192.168.1.104 192.168.1.205

# IP アドレスの一部
Allow from 10.1
Allow from 10 172.20 192.168.2

# ネットワーク/ネットマスク の対
Allow from 10.1.0.0/255.255.0.0

# ネットワーク/nnn CIDR 指定
Allow from 10.1.0.0/16

# IPv6アドレスとIPv6のサブネットは以下のように指定
Allow from 2001:db8::a00:20ff:fea7:ccea
Allow from 2001:db8::a00:20ff:fea7:ccea/10

Deny:
サーバがアクセスを拒否するホストを制御する。
(Deny from all|host|env=env-variable [host|env=env-variable] ...)
※ Allowと同じの為、省略。

19.<IfModule> / UserDir
<IfModule>:
モジュールの存在するかしないかに応じて処理する。
(<IfModule [!]module-file|module-identifier> ... </IfModule>)

  • module
    module と名付けられたモジュールが Apache に組み込まれていれば開始と終了の間に処理される。

  • !module
    module が組み込まれていない場合に処理する。

UserDir:
ユーザのドキュメントへのリクエストを受けた時に使う。
ユーザのホームディレクトリ中の、実際のディレクトリを設定する。
(UserDir directory-filename)

構文 内容
UserDir disabled (ユーザ名) リクエストを受けても変換しない。(ユーザ名)は省略可。
UserDir enabled (ユーザ名) リクエストを受けて変換する。(ユーザ名)は省略可。
UserDir directory-filename リクエストを受けて変換する内容を記載する。
以下の例を参照のこと。
# http://www.foo.com/~bob/one/two.html へのリクエスト
UserDir ディレクティブ   変換後のパス
UserDir public_html ~bob/public_html/one/two.html
UserDir /usr/web    /usr/web/bob/one/two.html
UserDir /home/*/www /home/bob/www/one/two.html

# クライアントに対してリダイレクトを送信
UserDir ディレクティブ   変換後のパス
UserDir http://www.foo.com/users    http://www.foo.com/users/bob/one/two.html
UserDir http://www.foo.com/*/usr    http://www.foo.com/bob/usr/one/two.html
UserDir http://www.foo.com/~*/  http://www.foo.com/~bob/one/two.html
httpd.conf
#
# UserDir: The name of the directory that is appended onto a user's home
# directory if a ~user request is received.
#
# The path to the end user account 'public_html' directory must be
# accessible to the webserver userid.  This usually means that ~userid
# must have permissions of 711, ~userid/public_html must have permissions
# of 755, and documents contained therein must be world-readable.
# Otherwise, the client will only receive a "403 Forbidden" message.
#
# See also: http://httpd.apache.org/docs/misc/FAQ.html#forbidden
#
<IfModule mod_userdir.c>
    #
    # UserDir is disabled by default since it can confirm the presence
    # of a username on the system (depending on home directory
    # permissions).
    #
    UserDir disabled

    #
    # To enable requests to /~user/ to serve the user's public_html
    # directory, remove the "UserDir disabled" line above, and uncomment
    # the following line instead:
    # 
    #UserDir public_html

</IfModule>

20.<Limit> / <LimitExcept>
<Limit>:
アクセス制御の適用を特定のHTTPメソッドのみに制限する。
(<Limit method [method] ... > ... </Limit>)

<LimitExcept>:
指定されたもの以外のHTTPメソッドにアクセス制御を制限する。
(<LimitExcept method [method] ... > ... </LimitExcept>)

httpd.conf
#
# Control access to UserDir directories.  The following is an example
# for a site where these directories are restricted to read-only.
#
#<Directory /home/*/public_html>
#    AllowOverride FileInfo AuthConfig Limit
#    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
#    <Limit GET POST OPTIONS>
#        Order allow,deny
#        Allow from all
#    </Limit>
#    <LimitExcept GET POST OPTIONS>
#        Order deny,allow
#        Deny from all
#    </LimitExcept>
#</Directory>

21.DirectoryIndex
クライアントがディレクトリをリクエストしたときに調べるリソースのリスト。
(DirectoryIndex local-url [local-url] ...)
仮にそれらが見つからず、Indexesオプションがセットされている場合には、ディレクトリのリストを生成する。

注意:ドキュメントが同じディレクトリ内に存在するは必要ありません。
DirectoryIndex index.html index.txt /cgi-bin/index.plとした場合、
index.htmlとindex.txtのどちらもディレクトリ内に存在しない場合には、/cgi-bin/index.plが実行される。

httpd.conf
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
# The index.html.var file (a type-map) is used to deliver content-
# negotiated documents.  The MultiViews Option can be used for the 
# same purpose, but it is much slower.
#
DirectoryIndex index.html index.html.var

22.AccessFileName
分散設定ファイルの名前を指定する。(AccessFileName filename [filename] ...)

リクエストを処理するとき、AllowOverride Noneと無効にされていない限り、そのドキュメントへのパス上にある全てのディレクトリから、ここで指定された名前の一覧の中で最初に見つかったファイルをそれぞれ設定ファイルとして読み込む。

httpd.conf
#
# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
#
AccessFileName .htaccess

23.<Files>
マッチするファイル名に適用されるディレクティブを設定する。
(<Files filename> ... </Files>)

httpd.conf
#
# The following lines prevent .htaccess and .htpasswd files from being 
# viewed by Web clients. 
#
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</Files>

24.TypesConfig
(ファイルの拡張子から判別する)MIME タイプ設定ファイルの位置を設定する。(TypesConfig file-path)

※ MIMEタイプとは...
電子メールに文字以外のデータを含める方式を定めたMIMEで、データ形式を識別するためのコードの体系。
転じて、Webのデータ送受信を行うHTTPなどでもデータの種類を表すコードとして利用されている。
(参照:IT用語辞典 e-Words / MIMEタイプ 【 MIME type 】)

httpd.conf
#
# TypesConfig describes where the mime.types file (or equivalent) is
# to be found.
#
TypesConfig /etc/mime.types

25.DefaultType
サーバがコンテントタイプを決定できないときに送られるMIMEコンテントタイプを設定する。
(DefaultType MIME-type|none)

構文 内容
DefaultType MIME-type text/plain(プレーンテキスト), image/png(PNG画像)などを指定する。
参照:wiki Multipurpose Internet Mail Extensions
DefaultType none コンテントタイプが分からない場合、
MIME タイプの情報を誤って付加することを防ぐ場合に無しとする。
httpd.conf
#
# DefaultType is the default MIME type the server will use for a document
# if it cannot otherwise determine one, such as from filename extensions.
# If your server contains mostly text or HTML documents, "text/plain" is
# a good value.  If most of your content is binary, such as applications
# or images, you may want to use "application/octet-stream" instead to
# keep browsers from trying to display binary files as though they are
# text.
#
DefaultType text/plain

26.MIMEMagicFile
(ファイルの中身から判別する)MIME タイプ設定ファイルの位置を設定する。(MimeMagicFile file-path)

httpd.conf
#
# The mod_mime_magic module allows the server to use various hints from the
# contents of the file itself to determine its type.  The MIMEMagicFile
# directive tells the module where the hint definitions are located.
#
<IfModule mod_mime_magic.c>
#   MIMEMagicFile /usr/share/magic.mime
    MIMEMagicFile conf/magic
</IfModule>

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
227