アプリ版:「スタンプのみでお礼する」機能のリリースについて

パーフェクトPHP[技術評論社]のP29まで終わりました。
次に、P30に入りました。そこで!
以下教本の中身です。
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 ■バーチャルホストの追加手順
 バーチャルホストを追加する際はまずドキュメントルートとなるデレクトリを作成します。
C:\xampp\apache\conf\extra\httpd-vhosts.confにバーチャルホストの設定を追加します。
<VirtualHost>で囲まれた部分をコピーして、ServerNameやDocumentRootの値を書き
かえて保存した後、Apacheを再起動します。また、必要に合わせて
C:\Windows\System32\drivrs\etc\hostsにドメインの指定を追加します。
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 以上ですが、

 「<VirtualHost>で囲まれた部分をコピーして、ServerNameやDocumentRootの値を書き
かえて保存します」
 とありますが! 「※何をやるのか!意味がまったく分かりません!?」
 以下が、C:\xampp\apache\conf\extra\httpd-vhosts.conf
 のファイルの中身の
「ServerNameやDocumentRootの値を書き
かえ」は
 教本・パーフェクトPHP P28の「ドキュメントルートの設定」
で、既に終了しているのでは!ないでしょうか!?
素人の考えですが、「※間違いでしょうか」
 ・・\httpd-vhosts.confの
 ファイルの現在のプログラムの中身です。宜しくお願いします。
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 # Virtual Hosts
#
# Required modules: mod_log_config

# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
<VirtualHost *:80>
ServerName study.localhost
DocumentRoot "C:/xampp/htdocs/study.localhost"
DirectoryIndex index.php index.html
<Directory "C:/xampp/htdocs/study.localhost">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>

##NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ##ServerName or ##ServerAlias in any <VirtualHost> block.
#
##<VirtualHost *:80>
##ServerAdmin webmaster@dummy-host.example.com
##DocumentRoot "C:/xampp/htdocs/dummy-host.example.com"
##ServerName dummy-host.example.com
##ServerAlias www.dummy-host.example.com
##ErrorLog "logs/dummy-host.example.com-error.log"
##CustomLog "logs/dummy-host.example.com-access.log" common
##</VirtualHost>

##<VirtualHost *:80>
##ServerAdmin webmaster@dummy-host2.example.com
##DocumentRoot "C:/xampp/htdocs/dummy-host2.example.com"
##ServerName dummy-host2.example.com
##ErrorLog "logs/dummy-host2.example.com-error.log"
##CustomLog "logs/dummy-host2.example.com-access.log" common
##</VirtualHost>

A 回答 (1件)

断っておきますが、ご提示した書籍は所持していません。



何をするのかわからないと言う前に、これが何をするための作業か理解していますか?
仮想的なホストを追加するためですよね
つまり、これは1 台のマシン上で二つ以上のウェブサイトを扱うための設定です

手元に書籍が無いので推測ですが
P.28で設定したドキュメントルート等は、追加されるホストとは関係ない設置済みのホストのはずです
httpd.confでバーチャルホストの設定を読み込むように設定済みのはずだと思いますので
既に設置されているのは study.localhost でアクセスできますよね?

さて、内容についてですが

行頭に # がない<VirtualHost *:80>から</VirtualHost>までの内容をコピーして(<VirtualHost *:80>、</VirtualHost>も含み
その下に貼り付けてください

それから追加するウェブサイトのDocumentRoot(コンテンツが置かれているディレクトリ)と
ServerName(http://hoge.piyo.jp でアクセスされて表示したいならhoge.piyo.jpと書く)を設定し直してください

あとはApacheを再起動させればいいです。

詳しくは
http://httpd.apache.org/docs/2.4/vhosts/
http://kazmax.zpp.jp/apache/apache5.html をご覧下さい

今回のご質問はプログラミングではなくサーバの設定ですのでカテ違いです
サーバ(Apache)のカテゴリーで、ご質問なさるべきでした

以上の内容やリンク先で理解できなかったのなら再度、そちらのほうにご質問なさると
知識に明るい方々がいらっしゃいますので回答がつきやすいかと思います
    • good
    • 0
この回答へのお礼

ご回答誠にありがとうございました。
 
 ご回答の内容と、サイトの内容も含め、全部ではないですが、
 読んで、PHPではないというということが分かりました。
 「バーチャルホスト」関係なので、私としましても、また未知の分野ですが、これも
 勉強しないと、この本を進めることができないので、がんばります^^
 
 質問をする場合は
 「サーバ(Apache)のカテゴリー」とのことなので、
 このスレッドを一度〆て、再度、Apache関係のカテゴリーに書き込みます。
 
 それとP29の内容も同様に記載しようと思います。

お礼日時:2013/11/23 07:31

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