XAMPP: Setting Up Virtual Hosts Using Apache Friends
Thursday, October 29th, 2009This is something I do often for development, but never actually knew if I was doing it correctly. I think I’ve finally gotten this right. What I want is: To be able to setup VirtualHosts in XAMPP and also define a PHP include path within that. I’m assuming you generally have an idea how to setup a VirtualHost in Apache.
The first step is to modify your Hosts file to point traffic to your local computer. My hosts file is here C:\WINDOWS\system32\drivers\etc\hosts, you’ll have to search for yours.
127.0.0.1 www.sun.com
127.0.0.1 sun.com
The next step is to define the VirtualHost within the httpd-vhosts.conf file in the conf directory of your XAMPP setup.
NameVirtualHost *
<VirtualHost *>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "C:\xampp\htdocs\sun"
ServerName www.sun.com
ServerAlias sun.com
ErrorDocument 404 /error.php
<Directory "C:\xampp\htdocs\sun">
Order allow,deny
Allow from all
</Directory>
<Directory "C:\xampp\htdocs\sun">
php_value include_path ".;C:\php\pear;C:\htdocs\sun\xx"
</Directory>
</VirtualHost>
Using a php_value directive you can define the include path for that VirtualHost right from conf file – thank God.




