Apache vhost設定(windows) 覚書
Apacheのvertual host設定について
通常使う127.0.0.1にいろいろな名前を定義すれば、
テスト環境を「http://localhost/」一本にしなくてもよい。
以下は、apacheフォルダが「C:\Apache2.2」であるという前提で・・・
例えば、現在、
Wordpressの勉強用の環境
某php開発作業用の環境
の2種類欲しいので、
1) C:\WINDOWS\system32\drivers\etc\hosts ファイルに
127.0.0.1 localhost
127.0.0.1 wp.local
127.0.0.1 test.local
を追加。
2) apacheの定義フォルダ(C:Apache2.2confextra)内のhttpd-vhosts.conf
まず、
#NameVirtualHost *:80
の先頭#をはずす。
次に、それぞれの環境のVirtualHost設定を行う。以下はwordpress用。
<VirtualHost *:80>
ErrorLog “logs/wp-error.log”
CustomLog “logs/wp-access.log” common
DocumentRoot C:Apache2.2 \ htdocs \ wordpress
ServerName wp.local
<Directory “C:\Apache2.2 \ htdocs \ wordpress”>
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost >
を追記。
php開発環境用の設定も追記して保存。
3) 最後は、apacheの定義フォルダ(C:Apache2.2conf)内のhttpd.conf
#Include conf/extra/httpd-vhosts.conf
の先頭#をはずす。