Monday, February 02, 2009

Apache with Virtual Hosts on Windows XP / XAMPP

I wanted my Apache / XAMPP to serve 3 different PHP projects / folders and my WinXP machine development machine.
I did following to allow that:

1. Add VirtualHosts - one for every root and add 'NameVirtualHost" directive. It is typically located in "extra\httpd-vhosts.confd" file. If you have your XAMPP in "C:\xampp", the path will be "C:\xampp\apache\conf\extra\httpd-vhosts.confd"

== httpd-vhosts.confd ===

NameVirtualHost 127.0.0.1


DocumentRoot "D:/xxx/yyy/zzz/prj1"
ServerName prj1



DocumentRoot "D:/xxx/yy/zzz/prj2"
ServerName prj2



DocumentRoot "D:/xxx/ttt/www/prj3"
ServerName prj3



2. Go to htppd.conf ( "C:\xampp\apache\conf\httpd.conf" in your XAMPP installation) and
verify that you hvae access permissions for every document root folder for prj1,2,3. Otherwwise
you end up with "Access Frobidden!" page.

=== httpd.conf ====


Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all


## The same "" definition should repeat for folder of prj2 and prj3


3. Go to Windows hosts file ("C\Windows\system32\drivers\etc\hosts" or similar) and add there new virtual hosts prj1,2,3, so you
can access them just by http://prj1 in your browser

=== hosts ===

127.0.0.1 prj1
127.0.0.1 prj2
127.0.0.1 prj3

4. Restart Apache and pint your browser to "prj1". You should be done now

No comments: