Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm running an apache development environment on my ubuntu desktop machine. When I start apache, I get the error

"apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
 ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName"

I attempted to fix this by adding a line to my apache.conf: servername myhost

This eliminates the error message. However, with this configuration, requests for vhosts are not honoured. Only the default host is accessible.

Is there a way I can eliminate this error, and have vhosts ?

share|improve this question

migrated from stackoverflow.com Nov 10 '09 at 16:49

This question came from our site for professional and enthusiast programmers.

5 Answers 5

Try adding ServerName vars to your Virtualhost configs.

For example, if you have the root ServerName var set to "www.myhost.com" under each you would set ServerName to "virtualhostname.myhost.com"

share|improve this answer

This is a serverfault question I believe, but did you do sudo a2ensite and activate the conf file, then apache2ctl graceful ?

You can do apache2ctl -S to see which virtualhosts are enabled. Also ensure that you updated /etc/hosts so that you have an entry pointing to 127.0.0.1.

share|improve this answer
    
Yes. I have made sure to enable the vhosts with a2ensite. I usually restart apache with /etc/init.d/apache restart apachectl -S shows that the vhosts are indeed enabled, even though I can't see them. –  bob Nov 10 '09 at 0:12

requests for vhosts are not honoured

Create a file called virtual.conf inside /etc/apache2/conf.d/.

The file should contain:

NameVirtualHost *

Reload apache (sudo /etc/init.d/apache2 reload) and virtualhosts should work.

share|improve this answer
    
When I do this, I still get the original error. I also get another error message that outputs itself repeatedly" [code] apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName [Tue Nov 10 13:06:04 2009] [error] VirtualHost :80 -- mixing * ports and non- ports with a NameVirtualHost address is not supported, proceeding with undefined results ... [/code] –  bob Nov 10 '09 at 0:10

Undo your modification in apache.conf and change your /etc/hosts file to:

127.0.0.1 localhost
127.0.1.1 mycomputername

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

Erasing the duplicated alias in the first line should solve the problem. Apparently /etc/hosts can only map one FQDN per line.

share|improve this answer
    
I'm not sure I understand your solution. Does this mean that my vhosts have to be technically on a different network? –  bob Nov 10 '09 at 0:25
    
I'm not sure to understand your comment :) The solution above solves the apache warning and has no impact on vhost. Did you try it? Do you still have problems? –  Pascal Thivent Nov 10 '09 at 0:57
    
Hi. I guess I'm just a little confused about the ip address that corresponds to the hostname in the snippet that you provide. I know that 127.0.0.1 refers to 'this host'. But I've never heard of using a '127.0.1.1' address. But, this is probably just me missing something simple. Anyway, I did give it a shot, but I'm afraid that I get the same result: the error message goes away, but the vhost is no longer accessible. –  bob Nov 10 '09 at 1:54
    
... this is probably just me missing something simple : yes (and this is actually how the /etc/hosts looks like in Karmic, this is how this bug has been fixed). I'm afraid that I get the same result: the error message goes away, but the vhost is no longer accessible. : I can guarantee that this would be for another configuration mistake, I have fully working vhost with this setup. –  Pascal Thivent Nov 10 '09 at 3:11
    
Regarding your first question, vhosts can be ip-based or name-based. So no, they don't have to be on a different network. –  Pascal Thivent Nov 10 '09 at 3:17

you can refer this Virtual Hosting. Hope it helps. :)

share|improve this answer

Your Answer

 
discard

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