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の許可の設定などを行いますが、バーチャルホストの場合どこで設定すればいいのでしょうか?
勉強不足なのは重々承知していますが、何卒よろしくお願い致します。
No.1ベストアンサー
- 回答日時:
>このファイルの設定方法が分かりません。
デフォルトのままでは、/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>
回答ありがとうございます。
丁寧に説明していただいたおかげで良く分かりました。
少しお聞きしたいのですが、今回の場合/var/www/htmlと言うディレクトリは使用していないので
/etc/httpd/conf/httpd.conf
にある
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/var/www/html">
…
</Directory>
は、消してしまっても問題ないのでしょうか?
度々申し訳ありませんがよろしくお願いします。
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
関連するカテゴリからQ&Aを探す
おすすめ情報
- ・漫画をレンタルでお得に読める!
- ・街中で見かけて「グッときた人」の思い出
- ・「一気に最後まで読んだ」本、教えて下さい!
- ・幼稚園時代「何組」でしたか?
- ・激凹みから立ち直る方法
- ・1つだけ過去を変えられるとしたら?
- ・【あるあるbot連動企画】あるあるbotに投稿したけど採用されなかったあるある募集
- ・【あるあるbot連動企画】フォロワー20万人のアカウントであなたのあるあるを披露してみませんか?
- ・映画のエンドロール観る派?観ない派?
- ・海外旅行から帰ってきたら、まず何を食べる?
- ・誕生日にもらった意外なもの
- ・天使と悪魔選手権
- ・ちょっと先の未来クイズ第2問
- ・【大喜利】【投稿~9/7】 ロボットの住む世界で流行ってる罰ゲームとは?
- ・推しミネラルウォーターはありますか?
- ・都道府県穴埋めゲーム
- ・この人頭いいなと思ったエピソード
- ・準・究極の選択
- ・ゆるやかでぃべーと タイムマシンを破壊すべきか。
- ・歩いた自慢大会
- ・許せない心理テスト
- ・字面がカッコいい英単語
- ・これ何て呼びますか Part2
- ・人生で一番思い出に残ってる靴
- ・ゆるやかでぃべーと すべての高校生はアルバイトをするべきだ。
- ・初めて自分の家と他人の家が違う、と意識した時
- ・単二電池
- ・チョコミントアイス
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
UPnPCJでポート開放が成功した...
-
プロキシ下でのファイルのアッ...
-
GetASFStreamというソフトにつ...
-
Microsoftアカウント1つを2台...
-
Windows11PCでMACアドレスの変...
-
ドメイン環境で同一ユーザで複...
-
クライアントとサーバーの間で...
-
ファイル名の文字色の変更は出...
-
1台のPCを複数アカウントで使...
-
集合型のポスト?あれの暗証番...
-
ステータスバーの文字の大きさ...
-
Mac起動時に毎回勝手にフォルダ...
-
[至急]windows10リモートデスク...
-
ドメイン再参加時に、エラー:ア...
-
windows11にて管理者アカウント...
-
「コンピュータ名」の設定について
-
社内のみで利用するWebサーバを...
-
Macのメールアカウント追加
-
Windows Server 2019 CALについて
-
ipadがインターネットに接続で...
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
Postfixでポート25での接続がで...
-
DNS(BIND)のエラーログについて
-
Linuxのnfsがうまくいきません。
-
X Server 10.8.3セキュリティに...
-
UPnPCJでポート開放が成功した...
-
squidで特定のページが開かない
-
VMWARE上にRedhatをインストー...
-
リモートデスクトップ、外部か...
-
Zabbix監視エージェントをイン...
-
ポート80の開け方について
-
グローバルIP一つ(固定)でのW...
-
自宅サーバーとルーターの作り方
-
ポート25が開けず、postfixが使...
-
Windows11PCでMACアドレスの変...
-
Microsoftアカウント1つを2台...
-
ファイル名の文字色の変更は出...
-
windows11にて管理者アカウント...
-
ドメイン再参加時に、エラー:ア...
-
ドメイン環境で同一ユーザで複...
-
[至急]windows10リモートデスク...
おすすめ情報