電子書籍の厳選無料作品が豊富!

OS:Scientific Linux6.2
Apache/2.2.15

Apacheのバーチャルホストの設定について現在勉強しております。
参考にしたサイト:http://scientificsrv.com/apache-virtualhost.shtml

私が今悩んでいるのが、DocumentRootになります。
2つのサイトを以下のディレクトリーに入れています。
ドメイン ディレクトリ
aaa.com /home/aaa/html
bbb.com /home/bbb/html

ここで、参考にしたサイトを元にしますと

/etc/httpd/conf.d/virtualhost-aaa.conf ← メインホスト用バーチャルホスト設定ファイル作成
<VirtualHost *:80>
ServerName aaa.com
DocumentRoot /home/aaa/html
</VirtualHost>

/etc/httpd/conf.d/virtualhost-bbb.conf ← 追加ホスト用バーチャルホスト設定ファイル作成
<VirtualHost *:80>
ServerName bbb.com
DocumentRoot /home/bbb/html
ErrorLog logs/virtual-error_log
CustomLog logs/virtual-access_log combined env=!no_log
</VirtualHost>

と言うようになります。
ここで、DocumentRootはそれぞれ設定していることになります。

そうするとApacheの設定ファイルのDocumentRootはどのように設定したらいいのでしょうか?
デフォルトでは以下のようになっています。
/etc/httpd/conf/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"

#
# 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#o …
# 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>

このファイルの設定方法が分かりません。デフォルトのままでは、/var/www/htmlを使用することになっています。バーチャルホストの方で設定しているのでここの設定はしなくていいのでしょうか?

また、
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/var/www/html">
では、htaccessやCGIの許可の設定などを行いますが、バーチャルホストの場合どこで設定すればいいのでしょうか?

勉強不足なのは重々承知していますが、何卒よろしくお願い致します。

A 回答 (2件)

>このファイルの設定方法が分かりません。

デフォルトのままでは、/var/www/htmlを使用することになっています。バーチャルホストの方で設定しているのでここの設定はしなくていいのでしょうか?
バーチャルホストに該当しないアクセスが来たときの値を設定します。
すべてバーチャルホストに該当するのであれば、「最初に記述した方」と同じ値にしておけば良いでしょう。


><Directory "/var/www/html">
>では、htaccessやCGIの許可の設定などを行いますが、バーチャルホストの場合どこで設定すればいいのでしょうか?

<VirtualHost></VirtualHost>の中で記述してください。

<VirtualHost *:80>
ServerName aaa.com
DocumentRoot /home/aaa/html
<Directory "/home/aaa/html">

</Directory>
</VirtualHost>
    • good
    • 0
この回答へのお礼

回答ありがとうございます。

丁寧に説明していただいたおかげで良く分かりました。

少しお聞きしたいのですが、今回の場合/var/www/htmlと言うディレクトリは使用していないので
/etc/httpd/conf/httpd.conf
にある
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/var/www/html">

</Directory>
は、消してしまっても問題ないのでしょうか?

度々申し訳ありませんがよろしくお願いします。

お礼日時:2012/02/26 20:49

>は、消してしまっても問題ないのでしょうか?


消す必要が無ければ残しておいてください。
もし消す場合は起動前の構文チェックを忘れずに。
    • good
    • 0
この回答へのお礼

回答ありがとうございます。

残しておくことにします。

2回にわたり回答していただきまして、本当にありがとうございました。

お礼日時:2012/02/27 10:16

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!


おすすめ情報