• How To?
  • Tips ‘n Tricks
  • WordPress
  • Snippets
  • Software
    • Browsers
    • Downloads
  • Web
  • Tools
    • Character Counter
    • chmod Calculator
    • Entities Encoder
    • Live HTML Editor
    • My IP
  • Contact
Twitter Facebook Google+ RSS
You are here: SumTips » How To? » Run Multiple Websites in WAMP by creating Multiple Virtual Hosts

Run Multiple Websites in WAMP by creating Multiple Virtual Hosts

Posted on February 27, 2011 by Renji | Short URL: http://sumtips.com/?p=3583

Virtual hosting is a method that allows one to run multiple web sites on a local computer. After setting it up, you would be able to access each web site using its own domain name.

In this tutorial, I will show how you can do it on WAMP, but other products are very similar, so you won’t have problems porting this.

Step 1: Open hosts file, located in C:\Windows\system32\drivers\etc\hosts, in you favorite text editor. Add a line similar to the one below and save the file.

127.0.0.1		mysite

Basically, this tells Windows to resolve IP 127.0.0.1 (which is localhost) to mysite.

For more sites, simply add more lines:

127.0.0.1		mysite
127.0.0.1		myothersite
127.0.0.1		localhost.localdomain

Step 2: Next, browse to C:\wamp\bin\apache\apache2.2.17\conf and open httpd.conf file in a text editor. In that, find a line that looks like this:

# Virtual hosts
#Include conf/extra/httpd-vhosts.conf

Uncomment it (remove the # symbol) and save it.

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

Step 3: Browse  to the folder C:\wamp\bin\apache\apache2.2.11\conf\extras and open httpd-vhosts.conf file in a text editor. Scroll to the end of the file and below code:

<VirtualHost *:80>
	ServerAdmin webmaster@localhost
	DocumentRoot "c:/wamp/www"
	ServerName localhost
	ErrorLog "logs/localhost-error.log"
	CustomLog "logs/localhost-access.log" common
</VirtualHost>
<VirtualHost *:80>
	#ServerAdmin webmaster@mysite
	DocumentRoot "c:/wamp/www/mysite"
	ServerName mysite
	ErrorLog "logs/mysite-error.log"
	CustomLog "logs/mysite-access.log" common
	<directory "c:/wamp/www/mysite">
		Options Indexes FollowSymLinks
		AllowOverride all
		Order Deny,Allow
		Deny from all
		Allow from 127.0.0.1
	</directory>
</VirtualHost>

You can see two directives for Virtual Host here. The first one preserves default localhost, so you can still access the WAMP dashboard, and the second one tells Apache where to look when a request for mysite is made. Rest of the code allows you to use .htaccess on this domain.

Now restart Apache server, and you should be able to access http://mysite to develop and test your site.

After completing this, you can run WordPress multisite on your local computer.


Tweet

Related posts:

  • Install a Portable Web Server on your USB Pen drive
  • Boot Windows from a Virtual Disk
  • Enable Voice Search Feature on WordPress and Other Websites
  • Batch File To Open Multiple Programs At Once
  • Set Favorite Websites & Custom Background Image on Chrome New Tab Page
Categories: How To? | Tags: Software, Windows
Create Multiple Links On A Single Image With Image Map
Encrypt a USB Flash Drive using TrueCrypt on Ubuntu

12 Responses to “Run Multiple Websites in WAMP by creating Multiple Virtual Hosts”

  1. aatif says:
    February 27, 2011 at 5:33 PM

    Used wamp server for some program . never thought this !! will try to use this .. learning never ends

    • Renji says:
      February 27, 2011 at 6:26 PM

      Yes, its a great piece of software. You will discover lots of other awesome features as well on exploring it.

  2. jas says:
    April 10, 2011 at 11:32 AM

    whats the point of the hosts file? wouldnt this be for the public? you could access each side publicly.
    and why use WAMP when a linux vm would perform better?
    you can use a turnkey appliance.

  3. Tahashibli says:
    April 19, 2011 at 8:10 PM

    Sir i am having a problem ,when ever i opening another site ,e.g base.com it is redirecting me to local host page , as i am doing to the same thing to another pc it works fine ,i tried to open base.com from local host it gave an error Unable to create file Cwampwwwwww.base.comhtdocswwwlogSERVER_NAMElogs.txt
    HelP Plzz (

  4. Kang Sawul says:
    August 15, 2011 at 12:58 PM

    Wow… good idea
    Is this hack no problem with wampp functionality?

    • Renji says:
      August 15, 2011 at 1:06 PM

      Hi Kang, no problem at all, it is not a hack but just a feature that Wamp provides. I am using it on my computer as well.

      • Kang Sawul says:
        August 15, 2011 at 1:56 PM

        oh, thank’s
        i will try your tips for my localhost

  5. siddhant says:
    January 3, 2012 at 6:44 PM

    I have done exactly what u have told but i am getting error message

    Forbidden

    You don’t have permission to access / on this server. can u tell why?

    • Morbo says:
      May 30, 2012 at 11:41 PM

      Change the line “Deny from all” to “Allow from all” and you will get access. It worked for me.

  6. Foxden Vixen says:
    March 9, 2012 at 5:53 AM

    I am trying to set this up on my PC so that I can test multiple WP websites. However, I also run IIS 7.5. My PC runs Windows 7 64 bit OS. I have already tweaked the httd.conf file for listening on :8080 since IIS uses localhost. 127.0.0.1:8080 works. Where you have 127.0.0.1 mysite am I limited as to the number of sites I can create? Also step 3 has me baffled. Do I change the NameVirtualHost *:80 to NameVirtualHost *:8080 since that is the port that Apache uses? Please answer this as I am sure I am NOT the only one that is trying to set this up in this manner. Thank you.

  7. Dave says:
    June 21, 2012 at 2:19 PM

    I had to change the virtualhost port from 80 to 8080 to get it to work for me, but great post. Thanks!

  8. How to host multiple web sites on WAMP | Edwin Hendarsyah’s Corner says:
    June 26, 2012 at 5:18 PM

    [...] can find detail article on these websites :http://www.trailheadinteractive.com and http://sumtips.com Share this:LinkedInTwitterLike this:LikeBe the first to like this. This entry was posted in [...]

  • Get Updates via Email

  • Recent Posts

    • CMS2CMS: Migrate Site from Drupal or Joomla to WordPress
    • WordPress: Add Preview Button in Distraction Free Writing
    • How to Activate or Deactivate Individual Jetpack Modules
    • Windows 8: Auto Update Defender with Windows Update Disabled
    • Automatically Start and Close Programs at Specific Time
    • How to Copy Code from Notepad++ with Syntax Highlighting
  • Random Posts

    • Now Watch Full Episodes of WWE Shows on YouTube
    • Word Tip: Paste Text Only Without the Formatting
    • Scaleable Full Screen Background Image with CSS3
    • Google's Page Speed Extension Now Available For Google Chrome
    • Know How to Say a Phrase or Word Correctly with Phras.in
    • Get Google Analytics on Your Desktop with Polaris
  • Categories

    • Blogging
    • Games
    • Google
    • How To?
    • Linux
    • Microsoft
      • Windows
    • Miscellaneous
    • Phone
    • Snippets
      • AutoHotkey Snippets
      • CSS Snippets
      • htaccess Snippets
      • JavaScript Snippets
      • PowerShell Snippets
      • WordPress Snippets
    • Social
    • Software
      • Browsers
    • Tips 'n Tricks
    • Wallpapers
    • Web
© SumTips. Contact | Sitemap | Privacy Policy