PHP7.1 / 5.6 / 5.2用のXAMPPから同じドキュメントルートを使うように設定をした際の覚え書きです。
-
目的
- ローカルのwikiをどのXAMPP起動中でも使用。
- 同じプログラムを複数バージョンで確認。
-
今回の目的のディレクトリ
C:\dev\vhosts\dev\htdocsC:\dev\vhosts\pukiwiki
-
設定ファイルの場所
(略)\XAMPPのディレクトリ\apache\conf\extra\httpd-vhosts.conf-
NameVirtualHost *:80を有効化すると、元のhtdocsにアクセスできなくなるので、そこをドキュメントルートにしたVirtualHostのディレクティブもvhostsに追加します。
-
XAMPP 7 / 5.6系(PHP 7 / 5.6 用 Apache 2.4)
- XAMPP 5.6.36 および XAMPP 7.1.11
- Apache 2.4なので、
Require all grantedを使用します。 - 今回の場合、ポータブル版を
C:\dev\xampppt5_6_36といった感じで置いています。
NameVirtualHost *:80
### XAMPP自身のhtdocsを使えるようにしておく
<VirtualHost *:80>
DocumentRoot "C:/dev/xampppt5_6_36/htdocs"
ServerName localhost:80
ErrorLog logs/error.log
CustomLog logs/access.log common
<Directory "C:/dev/xampppt5_6_36/htdocs">
Options Indexes
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
### 別バージョンのXAMPPから呼び出すディレクトリ
<VirtualHost *:80>
DocumentRoot "C:/dev/vhosts/dev/public_html"
ServerName dev.localhost
ErrorLog logs/error.log
CustomLog logs/access.log common
<Directory "C:/dev/vhosts/dev/public_html">
Options Indexes
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
### 別バージョンのXAMPPから呼び出すディレクトリその2
<VirtualHost *:80>
DocumentRoot "C:/dev/vhosts/pukiwiki"
ServerName wiki.localhost
ServerAlias pukiwiki.localhost
ErrorLog logs/error.log
CustomLog logs/access.log common
<Directory "C:/dev/vhosts/pukiwiki">
Options Indexes
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
XAMPP 1.6.4( PHP 5.2.4 用 Apache 2.2)
- Apacheが2.2系なので、Order Allow,Denyでアクセスを許可します。
- 今回の場合、xamppliteを
C:\dev\xampplite5_2_4に置いています。
NameVirtualHost *:80
### XAMPP自身のhtdocsを使えるようにしておく
<VirtualHost *:80>
DocumentRoot "C:/dev/xampplite5_2_4/htdocs"
ServerName localhost:80
ErrorLog logs/error.log
CustomLog logs/access.log common
<Directory "C:/dev/xampplite5_2_4/htdocs">
Order Allow,Deny
Allow from localhost
Options Indexes
AllowOverride All
</Directory>
</VirtualHost>
### 別バージョンのXAMPPから呼び出すディレクトリ
<VirtualHost *:80>
DocumentRoot "C:/dev/vhosts/dev/public_html"
ServerName dev.localhost
ErrorLog logs/error.log
CustomLog logs/access.log common
<Directory "C:/dev/vhosts/dev/public_html">
Order Allow,Deny
Allow from localhost
Options Indexes
AllowOverride All
</Directory>
</VirtualHost>
### 別バージョンのXAMPPから呼び出すディレクトリその2
<VirtualHost *:80>
DocumentRoot "C:/dev/vhosts/pukiwiki"
ServerName wiki.localhost
ServerAlias pukiwiki.localhost
ErrorLog logs/error.log
CustomLog logs/access.log common
<Directory "C:/dev/vhosts/pukiwiki">
Order Allow,Deny
Allow from localhost
Options Indexes
AllowOverride All
</Directory>
</VirtualHost>