Setup a Virtual Host on WAMP in 3 Steps

Like most developers, I work locally. I develop on Windows (don’t judge) and run WAMP. In WAMP, websites are located in the C:\wamp\www directory. You can access a website at localhost/mysite. You all know this. The standard way of hosting sites in WAMP is restrictive. Setting up a virtual host (vhost) provides several benefits:

  • Virtual Hosts make URLs cleaner – localhost/mysite vs mysite.local.
  • Virtual Hosts make permissions easier – restrict access for a single vhost on a local network vs permitting access to all sites on your local network.
  • Some applications require a “.” in the URL (ahem Magento). While you can setup by editing the Windows hosts file, creating a vhost is a better solution.

So, let’s setup a virtual host in WAMP.

  1. Include You Virtual Host Configuration File in Apache

    • Open your Apache configuration file located in C:\wamp\bin\Apache#.#.#\conf\httpd.conf, where #.#.# corresponds to the version of Apache that you are running in WAMP.

      Screenshot of the Apache configuration file in WAMP
      Apache Configuration File
    • Search for “LoadModule vhost_alias_module” (without the quotes) and uncomment the LoadModule vhost_alias_module modules/ directive below.

      Screenshot of the vhost_alias_module directive in the Apache  configuration
      Include Virtual Host Module
    • Search for “Virtual Hosts” (without the quotes) and uncomment the Include conf/extra/httpd-vhosts.conf directive below.

      Screenshot of the include virtual hosts directive in the Apache configuration file
      Include Virtual Host Configuration
    • Save and close the httpd.conf file.

  2. Update Your Virtual Host Configuration File

    • Open your Apache Virtual Hosts (vhost) configuration file located one directory down from the Apache configuration file directory in C:\wamp\bin\Apache#.#.#\conf\extra\httpd-vhosts.conf.

      Screenshot of the Apache virtual hosts configuration file in WAMP
      Apache Virtual Hosts
    • Add the configuration for your new vhost. While virtual host configuration is outside the scope of this article, I suggest you visit the Apache project’s documentation. It does a decent job of explaining the various configuration directives. I have included mine below with some comments as a starting point.

      Screenshot of a virtual host being added to Apache
      Add Virtual Host
    • Save and close the httpd-vhosts.conf file.

  3. Update Your Windows Hosts File

    • Open your Windows hosts file located in C:\Windows\System32\drivers\etc\hosts.

      Screenshot of the Windows hosts file
      Windows Hosts File
    • Add a new entry for the vhost you created in step 2.

      Screenshot of a new host being added to the Windows hosts file
      Add New Host
    • Save and close the hosts file.

    • Resart All Services in WAMP, pop open a web browser and access your new virtual host. Celebrate!

      Screenshot of the WAMP menu option to restart all services
      Restart All Services

      Screenshot of running on the johndugan.local virtual host in WAMP
      johndugan.local Virtual Host

57 thoughts on “Setup a Virtual Host on WAMP in 3 Steps”

  1. I would on a web server where there are more than a handful of virtual hosts. For my purposes of local development with just a few vhosts, I find it easier/simpler to keep the configuration in a single file. Once you get above 3 vhosts, then it makes sense to break things apart ~ IMHO.

  2. Thanks. I appreciate your tutorial. I am having issues saving the hosts file. It says “acceess denied”. I am not sure how to change permissions on the file. The way I tried, the options are greyed out. I am running as administrator.

  3. Hey JD,

    As you indicate, it sounds like a simple permissions issue. You’ll want to confirm that you have write permissions on the file. If you are running as administrator, I’m not sure why you are still running in to problems.

    Perhaps when you come across a solution you could update this thread to help out others that encounter the issue.

  4. Run your text editor as Administrator. (Right click then Run As Admin)

  5. I’m using Win7 and all my applications are running at port 80

    I’ve WAMP installed at c:wamp and i’ve my php project folder under c:wampwww as proj1,proj2 etc.,

    Now i tried to create virtual host with below steps

    1) edited ‘hosts’ file and added below

    2) Opened the file “httpd.conf” at “C:/wamp/bin/apache/Apache2.2.22/conf/” and uncommented the line “Include conf/extra/httpd-vhosts.conf”.

    3) Opened the file “httpd.vhosts.conf” at “C:/wamp/bin/apache/Apache2.2.22/conf/extra” and added the below

    Order Deny,Allow
    Allow from all

    after the above code added the below

    DocumentRoot “C:/wamp/www/proj1”

    4) Saved all the above edited files from step 1 through step 3, restarted the wamp server services.

    But, i’m unable to access my proj1 using “”. did i missed anything ? Also please take note by using “http://localhost:8081/” i’m able to see wampserver – server configuration page.

  6. Thanks for the awesome article!

    P.S. With WAMP server it looks like adding the thing to hosts file is not needed.

  7. Thanks for the tutorial. What editor do you use? It’s looks a lot nicer than notepad!

  8. Hi i have a question when i use for my site ( Magento with xampp on windows) other pc change in address bar the domain name with localhost ip

    PC with server ip ( created with your guide)
    other PC
    i write and after 2 second become on other pc, how can i fix it?

  9. You need to update your `hosts` file on all client machines that will be connecting through the LAN to your XAMPP server.

    The hosts file is located at: `C:WindowsSystem32driversetchosts`. Open it as admin with notepad and add the entry shown below.

    Depending on your virtual host setup, you may also need to explicitly allow connections from all client machines. See line 61 in the screenshot of my code editor in step 2.

  10. Hi Paul,

    There really isn’t. Tools like Vagrant and Docker have popped up more recently to address that issue. I have yet to move to one. The return on my time for moving would be nil at this point. However, if I were in a position where I needed to deploy the same environment across several machines, I’d strongly consider making the switch.

  11. After done this all changes. I restarted my wamp server but it stuck… local host is also not working.

    My purpose is I have multiple website on wamp server installed on windows 2012 and for each website I have multiple domains but they are from other domain providers. SO I want to host multiple websites on single wamp server and connecting them with domains..can you help me with that?

  12. Windows 2012? I don’t believe WAMP officially supports Windows Server.

    Regarding your domain issue, you’ll need to properly configure DNS with your registrar. Frankly, I have no clue what you are trying to do. I would not advise attempting to host sites publicly on Windows Server with WAMP. Just use IIS. Really though, if you can afford a license for Windows Server, you can probably afford good managed web hosting.

  13. Hey

    John, I now left the idea to use wamp server. I installed IIS.

    Here is what I am trying to do for my client-
    He has multiple domains in 1&1, arviex around 10 websites build in and WordPress and PHP. He has hosting on

    Now what client want is close He purchased windows server 2012 cloud and want his all domain direction to Windows Server cloud.
    What I did-
    I migrated all websites to windows Server from hostingsv. All website working fine on windows servers localhost IIS.

    My Problem-
    Windows Server has only one public IP. I am not able to find the way to direct all domains to windows server 2012 cloud where I migrated all websites data and databases.

    What I tried-

    I tried to changed one domains host IP to windows server public IP but it is not working.

  14. For the record, I would not (and don’t) host my own sites without deep domain knowledge.

    That said, I know as much as the next guy (or less) about IIS. I’m sure there is a way to setup virtual hosts like you can on NGINX and Apache. That’s what you’re after it sounds like. IPs are scarce these days, hosting multiple sites on the same IP is very common – it’s how every shared hosting package is setup.

  15. Hi, Can you help, please. I’ve followed through the post twice, but each time when I put “website.local” into the URL bar, it does a Google search >. copied your vhost file, with my own details > copied the servername into the host file…. and restarted wamp

  16. Hi john i have done all the changes but i have run my localhost on port 8080(localhost:8080). After doing changes my wampp server not starting why?

    i make my virtual host as


    DocumentRoot “C:/wamp/www/Project/public/”



    ErrorLog “C:/wamp/www/Project/logs/log.txt”

    CustomLog “C:/wamp/www/Project/logs” common

    Deny from all

    Allow from

    Can you help me?

  17. this 3 step do, after restart server but it not start service show offline…..pls give any suggestion

  18. i have a c# program that uses wamp server as its database, connection is fast on the main server, but my problem happens when another system tries to access wampserver from the mainserver, the application on the secondary system takes time to load…pls i need help

  19. John,
    First off, my wamp server is on port 81. Attached is a screen shot of my httpd-vhosts.conf & hosts files. When I go to pug.local it gives me an 404 error. What am I doing wrong? By the way I use WAMP Server 3.0

  20. Thank you very much. Great tutorial. I don’t have much interest how to configure my local Apache server, so I follow your tutorial again and again ๐Ÿ™‚

  21. Hello John, I tried your tutorial, but I get this error message on my localhost:
    The number of <Directory or does not match the number of ServerName in c:/wamp/bin/apache/apache2.4.23/conf/extra/httpd-vhosts.conf file
    Can you please explain me what should I put in Directory tags, because I basically copied your example and put my IP address instead of yours for iPad….

  22. Just wanted to say thank you for your guide, it helped me figure out what my issue was finally! Happy Easter!

  23. Hi John,

    I tried all the above techniques but unfortunately no one works for me.

    I tried to access URl like mysite.local/ & mysite.local:82/ but no luck, i am getting 502 Bad gateway error. with below error message :

    DNS error

    DNS error (the host name of the page you are looking for does not exist)

    Please check that the host name has been spelled correctly.
    I can access my localhost URL like localhost:82/, it is working for me.

    following are the details of my config files :


    LoadModule proxy_http_module modules/
    LoadModule proxy_module modules/

    Include conf/extra/httpd-vhosts.conf

    ServerName localhost:82

    Listen [::0]:82


    DocumentRoot “D:/wamp/www”
    ServerName localhost
    ServerAlias localhost

    AllowOverride All
    Options Indexes FollowSymLinks
    Require local

    DocumentRoot “D:/wamp/www/test”
    ServerName mysite.local
    ServerAlias http://www.mysite.local

    AllowOverride All
    Options Indexes FollowSymLinks
    Require local

    —————-etc/hosts—————– localhost
    ::1 localhost mysite.local
    ::1 mysite.local

    One thing i noticed when i connected through WiFi network i can able to access URL mysite.local:82 it is working as expected. but when i switched to company LAN then its stop working.

    Any help will be appreciated.

    Thanks in Advance

  24. Hi John, came across your page, I know that you’ll be able to help me with my wamp/ wordpress problem. I’m looking forward to learn more from you.

  25. I have almost the exact same problem!
    The difference is, I am able to access wamp server page from other devices, and the url is (my “server” pc),
    but when I try to access, I get redirected to localhost/mywptest and I get message “canโ€™t establish a connection to the server at localhost”

  26. hi. i did. but message came that file in already in process. what should i do. plz guide me

Leave a Reply

Your email address will not be published. Required fields are marked *