This is an article that I wrote few months ago in my own blog about setting up multiple virtual hosts in Windows version’s Apache HTTP Server. I decide to move it to this site so that those information technology related information will be focused in this site.
I’m managing a few sites’ source code and always need to test out the code I have modified before I upload the source files to my web server. I cannot rely on the single host (localhost) on my PC and change the Apache configuration file to point to the web site’s source folder whenever I need to do a testing.
The following setup is to enable you PC to host multiple websites at the same IP (127.0.0.1) with multiple virtual hosts.
Step 1 – Change httpd.conf
Make a backup of httpd.conf just in case you have make a mistake in changing the configuration file. Modify httpd.conf to add in the following code after the “LoadModule xxx” lines:
Where “C:\php\host1″ and “C:\php\host2″ is the path to files for virtual host “host1″ and “host2″ respectively. You can repeat the potion with the respective host names if you want host more websites.
Save the changes to httpd.conf and remember to restart Apache Httpd service.
Step 2 – Change Windows hosts file
Edit the file in “C:\[Windows]\System32\drivers\etc\hosts and add in the following lines:
Save the changes.
Step 3 – Test your changes
You can test your site by pointing your browser to http://host1/ and http://host2/
… and it’s done.