Tuesday, August 17, 2010

How to Configure Virtual Hosts with Apache using XAMPP

If you are using XAMPP (in Windows box), the easiest way to add a new website is to create a folder at /xampp/htdocs/ and place all your PHP or HTML files there.

But, I want to make use of the existing codes stored at some other folder in my machine!

Have no worries! Simply follow these steps:

STEP 1: Open httpd-vhosts.conf found at /xampp/apache/conf/extra/.

STEP 2: Append the following lines

# My New Website
Listen *:9000
<VirtualHost *:9000>
ServerName localhost:9000
DocumentRoot "D:/path/to/your/existing/code"

<Directory "D:/path/to/your/existing/code">
   AllowOverride All
   Options +Indexes
   DirectoryIndex index.php index.html
   Order allow,deny
   Allow from all
</Directory>

ErrorLog logs/error.log
CustomLog logs/access.log common
</VirtualHost>


STEP 3: Save the file.

STEP 4: Restart Apache.

STEP 5: Navigate http://localhost:9000/ and your website should show up! Voila!

NOTES:

(1) 9000 is just some port number, you may use your preferred port number.
(2) the forward slash (/) to indicate path is necessary.

No comments:

Post a Comment