• Home
  • About

szehau's weblog

Life, Internet, Software, Gadgets, Programming and Investments

  • life log
  • internet
  • programming
  • software
  • working holiday
  • gadget
  • project

Setup Multiple Virtual Host in Apache (Windows)

Recently I need to maintain multiple websites’ source code (PHP) at the same time at local host. Every time I need test another website, I need to modify the httpd.conf configuration file and restart the Apache server. After some researches on the internet, I manage to find a way to setup multiple virtual host.

  • 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\site1"
    ServerName site1
    </VirtualHost>
    <VirtualHost 127.0.0.1>
    DocumentRoot "C:\php\site2"
    ServerName site2
    </VirtualHost>
  • Where “C:\php\site1” and “C:\php\site2” is the path to files for virtual host “site1” and “site2” respectively.
  • Restart Apache Httpd service.
  • Edit the file in “C:\[Windows]\System32\drivers\etc\hosts and add in the following lines:
  • 127.0.0.1 site2
    127.0.0.1 site1
  • Point your browser to “http://site1/” or “http://site2” and will be execute to both site1 and site2 code.

Hope this bookmark help you too.

About Sze Hau

Geek. Love programming. Coffee addicted. Married with a child. Working towards financial freedom.

Email News Letter

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

More Posts

5 Essential Things You Need To Have At Your Home During The COVID-19 Pandemic

June 1, 2021 22:15 By Sze Hau

LED Downlight

Troubleshooting A Flickering LED Downlight

February 13, 2016 00:29 By Sze Hau

Repair A Broken iPhone Lightning Cable

January 30, 2016 00:54 By Sze Hau

Blog Network

  • Personal Fincance Personal Finance – Personal Money Tips, Stock Investment, Small Business and Make Money Online
  • Snippet IT Information technology news, ideas and experiences and opinions