Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question
    
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 '10 at 11:28
    
Can't this be done without editing hosts file? –  Emenims Feb 25 '10 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 '10 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. –  quack quixote Feb 25 '10 at 12:35
add comment

2 Answers

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:

share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.