ServerRootディレクティブ:相対パスの起点となるApacheがインストールされているディレクトリ

ServerRoot ディレクティブは Apache がインストールされているディレクトリを設定するのに使用します。 httpd.conf ファイル内でディレクトリを相対パスで記述した場合、 ServerRoot ディレクティブで設定されたディレクトリが相対パスの起点となります。ここでは Apache の ServerRoot ディレクティブの使い方について解説します。

(Last modified: )

ServerRootディレクティブ

ServerRoot ディレクティブは Apache がインストールされているディレクトリを設定します。書式は次のとおりです。

ServerRoot ディレクトリ

記述できる場所は httpd.conf です。

ServerRoot ディレクティブには絶対パスで指定する必要があります。例えば Apache をインストールしたディレクトリが d:/pg/Apache/Apache24 だった場合には次のように記述します。

ServerRoot d:/pg/Apache/Apache24

Apache の設定ファイルである httpd.conf の中でディレクティブに対して相対パスを使ってパスを記述する場合、 SeverRoot ディレクティブで指定したディレクトリが起点となります。例えば次のようにあるディレクティブに対して相対パスでファイル名が指定されていた場合、 ServerRoot ディレクティブに設定されている d:/pg/Apache/Apache24 が起点となるので次の 2 つは同じ結果となります。

xxxxxx conf/extra/xxxx.conf
xxxxxx d:/pg/Apache/Apache24/conf/extra/xxxx.conf

httpd.conファイルでの記述

httpd.conf ファイルにはデフォルトで次のように記述されています。

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to specify a local disk on the
# Mutex directive, if file-based mutexes are used.  If you wish to share the
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.
#
Define SRVROOT "d:/pg/Apache/Apache24"

ServerRoot "${SRVROOT}"

まず Define ディレクティブを使って変数 SRVROOT に対して Apache をインストールしたディレクトリのパスを設定しています。そのあとで ServerRoot ディレクティブに対して変数 SRVROOT に格納されている値を設定しています。

※ Define ディレクティブについては「Defineディレクティブ:変数を定義する」を参照されてください。

-- --

Apache の ServerRoot ディレクティブの使い方について解説しました。

( Written by Tatsuo Ikura )

Profile
profile_img

著者 / TATSUO IKURA

プログラミングや開発環境構築の解説サイトを運営しています。