XAMPP for windows(XP)のバーチャルホスト : apache

Pocket

XAMPP for windowsでバーチャルホストを設定する(Windows XP)。

MacはXAMPP for Macのバーチャルホスト : Macにメモ。

設定するファイル

バーチャルホストの設定ファイル(XAMPPをC:xamppにインストールしたとき)。

  • httpd.conf
    C:xamppapacheconfhttpd.conf
  • httpd-vhosts.conf
    C:xamppapacheconfextrahttpd-vhosts.conf
  • hosts
    C:WINDOWSsystem32driversetc

ファイルの設定

C:xamppにdocsフォルダを作成して案件ごとにフォルダを作成する。

C:xamppdocsexample.com
                  |-- index.html
                  |-- ....

example.localhostでアクセスする。

またC:xampphtdocsは自身の開発用にする。localhostでアクセスする。

httpd.confの設定

バーチャルホストを有効にする。

# Virtual hosts
Include conf/extra/httpd-vhosts.conf      ← コメントアウト

httpd-vhosts.conf

example.localhostディレクトリをDocumentRootに設定する。

<VirtualHost *:80>
    DocumentRoot "C:xamppdocsexample.com"
    ServerName example.localhost
    ErrorLog "logs/example.localhost-error_log"
    CustomLog "logs/example.localhost-access_log" common
    <Directory "C:xamppdocsexample.com">
        order deny,allow
        allow from ALL
    </Directory>
</VirtualHost>

Directoryディレクティブの設定をしないとAccess forbiddenになった。

» ときどきぷろぐらま。 xamppでバーチャルホストを設定。

バーチャルホストをしたらlocalhostでhtdocsにアクセスできなくなった。NameVirtualHost *:80にの設定を追加する。この設定はhttpd.confのDocumentRootディレクティブより優先される。

NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:xampphtdocs"
</VirtualHost>

hosts

127.0.0.1       localhost
127.0.0.1       example.localhost
C:WINDOWSsystem32driversetc

コメント

No comments yet.

コメントの投稿

改行と段落タグは自動で挿入されます。
メールアドレスは表示されません。