Apache | Apacheの基本設定 | 設定ファイル(httpd.conf)の場所と補助設定ファイルの読み込み

Apacheの設定はhttp.confファイルで行うが、別のファイルに設定を書き、それをhttp.confファイルに読み込ませることもできる。ここでは、http.confファイルの場所と、別途用意した補助設定ファイルを読み込む方法について説明する。

http.confファイルの場所

Apacheをインストールすると、ファイル構成は次のようになる。

C:\apache\Apache24>dir
 C 드라이브의 볼륨에는 이름이 없습니다.
 볼륨 일련 번호: XXXX-XXX

 C:\apache\Apache24 디렉터리

2019-11-26  오후 10:39    <DIR>          .
2019-11-26  오후 10:39    <DIR>          ..
2015-04-16  오전 05:53            13,740 ABOUT_APACHE.txt
2019-11-26  오후 10:39    <DIR>          bin
2019-11-26  오후 10:39    <DIR>          cgi-bin
2019-08-09  오후 11:37                59 CHANGES.txt
2019-11-26  오후 10:39    <DIR>          conf
2019-11-26  오후 10:39    <DIR>          error
2019-11-26  오후 10:39    <DIR>          htdocs
2019-11-26  오후 10:39    <DIR>          icons
2019-11-26  오후 10:39    <DIR>          include
2016-05-18  오전 02:59             3,869 INSTALL.txt
2019-11-26  오후 10:39    <DIR>          lib
2019-08-09  오후 11:38            44,480 LICENSE.txt
2019-11-28  오후 12:30    <DIR>          logs
2019-11-26  오후 10:39    <DIR>          manual
2019-11-26  오후 10:39    <DIR>          modules
2019-08-09  오후 11:38             2,865 NOTICE.txt
2019-08-09  오후 11:50            41,993 OPENSSL-NEWS.txt
2019-08-09  오후 11:50             4,545 OPENSSL-README.txt
2014-01-24  오전 01:33             4,752 README.txt
               8개 파일             116,303 바이트
              13개 디렉터리  459,275,866,112 바이트 남음

C:\apache\Apache24>

Apacheの設定ファイルであるhttp.confは、(インストールディレクトリ)\Apache24\conf\ディレクトリに入っている。

C:\apache\Apache24\conf>dir
 C 드라이브의 볼륨에는 이름이 없습니다.
 볼륨 일련 번호: XXXX-XXX

 C:\apache\Apache24\conf 디렉터리

2019-11-26  오후 10:39    <DIR>          .
2019-11-26  오후 10:39    <DIR>          ..
2019-08-09  오후 11:50             1,820 charset.conv
2019-11-26  오후 10:39    <DIR>          extra
2019-11-28  오후 12:30            20,555 httpd.conf
2019-08-09  오후 11:50            13,449 magic
2019-08-09  오후 11:50            62,702 mime.types
2019-05-28  오후 10:12            11,259 openssl.cnf
2019-11-26  오후 10:39    <DIR>          original
               5개 파일             109,785 바이트
               4개 디렉터리  459,279,749,120 바이트 남음

C:\apache\Apache24\conf>

設定を変更する前に、バックアップとしてhttp.confファイルを別名でコピーして保存しておく。設定を変更する場合、http.confファイルはテキストファイルなので、テキストエディタで開く。

補助設定ファイルを読み込む方法

現在のバージョンでは、一部の設定項目は別ファイルに分離されており、必要に応じてhttpd.confファイルから読み込めるようになっている。標準で提供される補助設定ファイルは、(インストールディレクトリ)\Apache24\conf\extra\ディレクトリに保存されている。

http.confファイルから別の設定ファイルを読み込むには、Includeディレクティブを使用する。具体例として、http.confファイルの末尾を見ると、次のような内容がある。

# Supplemental configuration
#
# The configuration files in the conf/extra/ directory can be 
# included to add extra features or to modify the default configuration of 
# the server, or you may simply copy their contents here and change as 
# necessary.

# Server-pool management (MPM specific)
#Include conf/extra/httpd-mpm.conf

# Multi-language error messages
#Include conf/extra/httpd-multilang-errordoc.conf

# Fancy directory listings
#Include conf/extra/httpd-autoindex.conf

# Language settings
#Include conf/extra/httpd-languages.conf

# User home directories
#Include conf/extra/httpd-userdir.conf

# Real-time info on requests and configuration
#Include conf/extra/httpd-info.conf

# Virtual hosts
#Include conf/extra/httpd-vhosts.conf

# Local access to the Apache HTTP Server Manual
#Include conf/extra/httpd-manual.conf

# Distributed authoring and versioning (WebDAV)
#Include conf/extra/httpd-dav.conf

# Various default settings
#Include conf/extra/httpd-default.conf

# Configure mod_proxy_html to understand HTML4/XHTML1
<IfModule proxy_html_module>
Include conf/extra/proxy-html.conf
</IfModule>

現在はすべて先頭に#があるためコメントになっており、実際には補助設定ファイルを読み込んでいない。ここでユーザーディレクトリ用の補助設定ファイルを読み込みたい場合は、行頭の#を削除して次のように記述する。

# User home directories
Include conf/extra/httpd-userdir.conf

これで補助設定ファイルconf/extra/httpd-userdir.confが読み込まれる。Includeディレクティブの使い方の詳細は「設定ファイルの読み込み(Include)」を参照する。