1

How can I set up multiple apache local web sites on Ubuntu?

I added the following to httpd.conf:

<VirtualHost *:80>
DocumentRoot "/wwwroot/htdocs/firstsite/"
ServerName www.vhostsite.com
</VirtualHost>

Now I try to go to www.vhostsite.com but browser says he can't find server.

Though, firstsite folder is created in htdocs, and it contains index.html (that is intended to show up in browser)

wwwroot is directory where apache is installed

4
  • Your browser needs to know an IP address, so add the dummy www.vhostsite.com to your /etc/hosts file, like I wrote.
    – Arjan
    Feb 25, 2010 at 11:28
  • Can't this be done without editing hosts file?
    – Emenims
    Feb 25, 2010 at 11:41
  • 1
    That would require a DNS server. Or registering a true domain, and mapping your server to your public IP address. (But even then some home routers require you to use the hosts file, for otherwise the browser cannot connect to that public IP address from within your own network.)
    – Arjan
    Feb 25, 2010 at 12:02
  • @Arjan is right, if you want www.vhostsite.com to resolve to localhost you need hosts or DNS. if you run DD-WRT/OpenWRT on your home router you may be able to tweak it to add your own DNS settings there; hosts is easier tho. Feb 25, 2010 at 12:35

2 Answers 2

2

Your browser needs to know an IP address, while the server then needs more details as for which site to serve. So, to host multiple sites on localhost you cannot serve all of them at http://localhost or http://127.0.0.1. Instead:

1

you can use rapache to have a GUI to setup your domains instead of editing the config by hand.

You must log in to answer this question.