Apache httpd.confの編集
Apache のダウンロードおよび Windows 環境へのインストール方法について解説します。
PC環境に合わせて64bitにダウンロードをしています。
httpd.confのファイル場所
ここまで、httpd.confファイルの解説は以上で終了です。
httpd.confのファイル編集
メモ帳を使わないことをお勧めします。
#タグはコメントアウトなので、気を付けてください。
ここから、「Localhost」に関するプログラムの解説をしていきます。
37行目あたり
「httpd」のフォルダにリネームしているため、「c:/Apache24」の名前を変更
Define SRVROOT "c:/Apache24"
変更
Define SRVROOT "c:/httpd"
LoadModule関連の設定
モジュール関連については「モジュール一覧」に記載しています。
#LoadModule expires_module modules/mod_expires.so
#LoadModule headers_module modules/mod_headers.so
#LoadModule rewrite_module modules/mod_rewrite.so
#LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
#LoadModule ssl_module modules/mod_ssl.so
変更
Define SRVROOT "c:/httpd"
227行目あたり
コメントアウトをしてサーバーのホスト名を変更
#ServerName www.example.com:80
変更
# コメントアウト
ServerName localhost:80
234行目あたり
Directoryの中身を変更
<Directory />
AllowOverride none
Require all denied
</Directory>
変更
<Directory />
Options FollowSymLinks Indexes Includes
AllowOverride All
Require all granted
</Directory>
252行目あたり
「.htaccess」のファイルで設定可能にするために、Directoryの中に「AllowOverride None」を「AllowOverride All」に変更
<Directory "${SRVROOT}/htdocs">
#
# 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.4/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:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
変更
<Directory "${SRVROOT}/htdocs">
#
# 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.4/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:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>
284行目あたり
ファイル読み込みに必要な拡張子の関連付け
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
変更
今回は、HTMLファイルのみだけとなります。ほかのファイルを読み込みたいときは「index.html」の横にスペースを開けて追加してください。
例)index.html index.xml index.php
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
399行目あたり
Server-Side Includes を有効にする
<IfModule mime_module>
#
# TypesConfig points to the file containing the list of mappings from
# filename extension to MIME-type.
#
TypesConfig conf/mime.types
#
# AddType allows you to add to or override the MIME configuration
# file specified in TypesConfig for specific file types.
#
#AddType application/x-gzip .tgz
#
# AddEncoding allows you to have certain browsers uncompress
# information on the fly. Note: Not all browsers support this.
#
#AddEncoding x-compress .Z
#AddEncoding x-gzip .gz .tgz
#
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
#
# AddHandler allows you to map certain file extensions to "handlers":
# actions unrelated to filetype. These can be either built into the server
# or added with the Action directive (see below)
#
# To use CGI scripts outside of ScriptAliased directories:
# (You will also need to add "ExecCGI" to the "Options" directive.)
#
#AddHandler cgi-script .cgi
# For type maps (negotiated resources):
#AddHandler type-map var
#
# Filters allow you to process content before it is sent to the client.
#
# To parse .shtml files for server-side includes (SSI):
# (You will also need to add "Includes" to the "Options" directive.)
#
#AddType text/html .shtml
#AddOutputFilter INCLUDES .shtml
</IfModule>
変更
「AddType text/html .shtml」、「AddOutputFilter INCLUDES .shtml」2ヶ所をコメントアウトにする。
<IfModule mime_module>
#
# TypesConfig points to the file containing the list of mappings from
# filename extension to MIME-type.
#
TypesConfig conf/mime.types
#
# AddType allows you to add to or override the MIME configuration
# file specified in TypesConfig for specific file types.
#
#AddType application/x-gzip .tgz
#
# AddEncoding allows you to have certain browsers uncompress
# information on the fly. Note: Not all browsers support this.
#
#AddEncoding x-compress .Z
#AddEncoding x-gzip .gz .tgz
#
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
#
# AddHandler allows you to map certain file extensions to "handlers":
# actions unrelated to filetype. These can be either built into the server
# or added with the Action directive (see below)
#
# To use CGI scripts outside of ScriptAliased directories:
# (You will also need to add "ExecCGI" to the "Options" directive.)
#
#AddHandler cgi-script .cgi
# For type maps (negotiated resources):
#AddHandler type-map var
#
# Filters allow you to process content before it is sent to the client.
#
# To parse .shtml files for server-side includes (SSI):
# (You will also need to add "Includes" to the "Options" directive.)
#
# コメントアウト
AddType text/html .shtml
# コメントアウト
AddOutputFilter INCLUDES .shtml
</IfModule>
ここまで「httpd.conf」の基本設定の解説は以上です。


