Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've just setup a development server. I did 2 apache virtualhost, using 2 different domains from

The weird thing is, I had to add both in the etc/hosts file, wich I never had to in the past when I configured other vps :o

I never had to edit that file in the past, I had to edit it so both of my domain point to my vps's ip. Before editing it, I only had 1 of the two pointing to it (the hostname I entered when I oredered my vps).

Is it because I don't run my own DNS server?

Now everything work A1, but If someone could tell me why I have to play with etc/hosts, I would appreciate it.



::1 localhost.localdomain localhost localhost.localdomain localhost  brico  brico-redmine

apache2ctl -S

root@brico:~# apache2ctl -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
         default server (/etc/apache2/sites-enabled/000-default:1)
         port 80 namevhost (/etc/apache2/sites-enabled/000-default:1)
         port 80 namevhost (/etc/apache2/sites-enabled/redmine:1)
Syntax OK virtualhost file

<VirtualHost *:80>
    DocumentRoot /opt/redmine/public
    PassengerPoolIdleTime 0
        <Directory "/opt/redmine/public">
                PassengerEnabled on
                Options -MultiViews
share|improve this question
What exactly did you put in your hosts file? And is the apache server hosted at some datacenter, or on your private LAN? – Martijn Heemels Sep 12 '10 at 15:49
some datacenter, but they dont offer DNS server, I would have to install one myself. But Instead, I just used a free dns service (noip) – allaire Sep 12 '10 at 15:57
Please edit your question and paste it there, instead of a remote service such as That way people don't have to leave the page, and your question will not depend on another service's function. – Martijn Heemels Sep 12 '10 at 15:58
up vote 1 down vote accepted

Your browser has to figure out which IP address a hostname points to. It can do this via the hosts file, via a private DNS server, or via a public DNS server.

Since you already registered two hostnames you shouldn't need those lines in your hosts file. You effectively have a public dns server, although a simple one.

Just make sure your Apache virtualhosts are configured to respond to the right ServerName. One should respond to and the other to Remove both those lines from your hosts file, otherwise it will take precedence.

If you also want to be able to just use the words brico and brico-redmine in your browser, you'll need to add to the search-domain in your dns-client settings. Let us know which client OS you use, if you want specific advice.

share|improve this answer
hey, thanks for your help so far. it's weird because I have both ServerName different in both virtualhost, and it wasn't working :o I'm on ubuntu 10.04 – allaire Sep 12 '10 at 16:06
If you could show your virtualhost config we could probably find the cause. Run 'apache2ctl -S' from the command-line. – Martijn Heemels Sep 12 '10 at 16:12
OK just added to the bottom of my post – allaire Sep 12 '10 at 16:34
I've also added the content of my virtualhost file! – allaire Sep 12 '10 at 16:37
Got it working, I just rebooted the VPS, removed all the lines my /etc/hosts, and voilà! thanks a lot for your help – allaire Sep 12 '10 at 16:47

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.