LoginSignup
2
3

More than 5 years have passed since last update.

Apache設定ファイルにおけるSection1と2の違い、あるいはGlobal EnvironmentとMain server configurationの違いについて

Posted at

Apache設定ファイル (/etc/httpd/conf/httpd.conf) にはSectionという概念があります。
このSection1とSection2の違いについて明確に説明できるでしょうか?

### Section 1: Global Environment
#
# The directives in this section affect the overall operation of Apache,
# such as the number of concurrent requests it can handle or where it
# can find its configuration files.
#
### 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.

セクション1は「グローバル」、セクション2は「メイン」と書かれているのですが、どっちも言葉の意味が似てるのでわかりにくいですね。

設定ファイル上もセクション1と2の間に明確な文法的仕切りがない(単にコメントで仕切られているだけ)ことが、わかりにくさを後押ししているようです。

わけて理解する必要あるの?

なぜセクション1と2の違いを理解する必要があるのかというと、「コンテキスト」が関係するからです。

セクション コンテキスト
セクション1 サーバ設定ファイル(server config)
セクション2 バーチャルホスト(virtual host)

違いは<VirtualHost>内で設定を上書きできるかどうか

セクション2に書いてる設定は、「バーチャルホストのデフォルト設定」です。
つまり、個別の 内で上書きが可能です。

なので、セクション1の範疇であるServerRoot,User,PidFileなどは<VirtualHost>内で上書きすることはできないのです。

たしかによく考えてみると、UserPidFileなどはリクエスト毎の設定ではなくデーモン単位の設定なので、これはうなづけますね。

2
3
0

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
2
3