• Home
  • About

Snippet IT

IT News, Programming, Internet and Blogging

  • Programming and Scripting
  • Tips and Tricks
  • Software and Hardware
  • New and Happening
You are here: Home / Programming and Scripting / Multiple Virtual Hosts in Apache HTTP Server (Windows)

Multiple Virtual Hosts in Apache HTTP Server (Windows)

April 2, 2008 by Sze Hau Leave a Comment

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:


NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
DocumentRoot "C:\php\host1"
ServerName host1
</VirtualHost>
<VirtualHost 127.0.0.1>
DocumentRoot "C:\php\host2"
ServerName host2
</VirtualHost>

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:


127.0.0.1 host1
127.0.0.1 host2

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.

More from my site

  • Java: How To Create A Simple Web Server Using HttpServerJava: How To Create A Simple Web Server Using HttpServer
  • Ensure Data Submitted/Viewed Online is SecuredEnsure Data Submitted/Viewed Online is Secured
  • Enable .htaccess and URL rewriting in Apache HTTP Server for WindowsEnable .htaccess and URL rewriting in Apache HTTP Server for Windows
  • SherWeb: Hosted Exchange, Web Hosting, SharePoint Hosting, Hosted CRMSherWeb: Hosted Exchange, Web Hosting, SharePoint Hosting, Hosted CRM
  • PHP: How to Protect Password in Database – Password HashingPHP: How to Protect Password in Database – Password Hashing
  • Virtualmin: How To Install Virtualmin in CentOSVirtualmin: How To Install Virtualmin in CentOS

Filed Under: Programming and Scripting Tagged With: apache, domain, HTTP, httpd.conf, virtual host

About Sze Hau

Geek. Love programming. Coffee addicted. Married with two children. Working towards financial freedom.

Leave a Reply Cancel reply

Advertisement

  • Facebook
  • Google+
  • Instagram
  • Twitter

Email News Letter

Sign up to receive updates daily and to hear what's going on with us

Software and Hardware

MD5 and SHA1 Checksum Using Windows

July 5, 2017 By Sze Hau Leave a Comment

Blog Network

  • Personal Fincance Personal Finance – Personal Money Tips, Stock Investment, Small Business and Make Money Online
  • szehau's weblog Life, Internet, Software, Gadgets, Programming and Investments

Snippet IT

This is the place where I want to share anything about information technology.

Search

Recent

  • MD5 and SHA1 Checksum Using Windows
  • MD5 and SHA1 Checksum Using Linux
  • Java: Unlimited Strength Jurisdiction Policy
  • WordPress: How To Change Admin Username
  • Linux: How To Compress And Decompress Folders And Files

Tags

Adsense advertisement advertising apache blog blogging tips C# EGPC error estimation format format Integer Gmail Google Google Adsense Google Chrome Google Search Engine Google search result how to HTTP internet marketing Java JavaScript Linux money password performance PHP programming search engine optimization secure security short URL SQL static constructor String tiny URL Tips and Tricks twitter video Windows Vista Wordpress wordpress plugin wordpress theme Youtube

Copyright © 2025 · Magazine Pro Theme on Genesis Framework · WordPress · Log in