Wednesday, June 17, 2009

Configuring local virtual hosts with Apache/XAMPP

Add these to c:/xampp/apache/conf/extra/httpd-vhosts.conf:

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot C:/xampp/htdocs
ServerName localhost
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot path/to/your/project
ServerName yourvirtualhostname

ErrorLog path/to/your/project/error_log
CustomLog path/to/your/project/access_log common

<Directory "path/to/your/project">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

The second one is your new virtual hosts and the first one guarantees access to non-virtual hosts still work.

You also need to add your new host name to c:/WINDOWS/system32/drivers/etc/hosts:

127.0.0.1 yourvirtualhostname

No comments:

Post a Comment