Apaheにバーチャルホストを設定するときにhttpd-vhosts.confを設定したりコマンドプロンプトを触ったり色々と面倒な手順がありますが、httpd.confの編集だけで出来る方法をご紹介します。
XAMPPのバージョンは3.2.2です。
Listen(ポート)の設定
httpd.confの58行目くらいに”Listen80″とあります。その下に好きなポート番号を書きます。
例えば、”Listen 8001″と書きます。
バーチャルホストの設定
次に、httpd.confの一番下にこのように書きます。
<VirtualHost *:8001>
ServerName base
DirectoryIndex index.html
AddDefaultCharset UTF-8
DocumentRoot C:\web\testsite\htdocs
<Directory "C:\web\testsite\htdocs">
AddType text/html .shtml .html
AddHandler server-parsed .shtml .html
Options Indexes MultiViews FollowSymlinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
これでApacheを再起動して”localhost:8001″にアクセスすれば”C:\web\testsite\htdocs”をルートとした仮想サーバにアクセスすることができます。
あとはこの”Listen”と”VirtualHost”の記述を増やしていくだけですね。ルートとするディレクトリも特に制約も無く、Dドライブなどでも設定できます。
もしバーチャルホストの設定が面倒だったらお試しください。



