I keep getting this warning when I (re)start Apache.
* Restarting web server apache2
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[ OK ]
This is the content of my etc/hosts
file:
#127.0.0.1 hpdtp-ubuntu910
#testproject.localhost localhost.localdomain localhost
#127.0.1.1 hpdtp-ubuntu910
127.0.0.1 localhost
127.0.0.1 testproject.localhost
127.0.1.1 hpdtp-ubuntu910
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
This is the content of my /etc/apache2/sites-enabled/000-default
file:
<VirtualHost *:80>
ServerName testproject.localhost
DocumentRoot "/home/morpheous/work/websites/testproject/web"
DirectoryIndex index.php
<Directory "/home/morpheous/work/websites/testproject/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /lib/vendor/symfony/symfony-1.3.2/data/web/sf
<Directory "/lib/vendor/symfony/symfony-1.3.2/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
When I go to http://testproject.localhost
, I get a blank page.
Can anyone spot what I am doing wrong?
By default Ubuntu doesn't specify a ServerName in the Apache configuration, because it doesn't know what the name of your server is. It tries a reverse lookup on your IP address, which returns nothing, so it just has to use the IP address as the ServerName.
To fix it, either add a ServerName directive outside of any virtual host - e.g. in
/etc/apache2/httpd.conf
, or set up a reverse DNS response for your primary IP address - in this case, 127.0.1.1It's perfectly fine to ignore it also.
Here's a quick fix:
Another way around that warning is to put a fully qualified domain name on the
127.0.1.1
line of/etc/hosts
. It doesn't even have to be a fqdn that would actually resolve to anything on a dns server.would do the trick, while also preserving the behavior of any programs that aren't expecting the extra
.lan
. The order is important; names with more levels should be specified first, as in this example where the.lan
address comes before the other address.This solution works for my development needs:
Background:
Debian Linux Sid:
VirtualHost Development: I have 10 server names (10 virtualhost entries inside sites-available)
I assigned each one a unique localhost IP address inside
/etc/hosts
:If you're going to add another virtualhost (I have quite a few for development) add an entry to another localhost IP address, and enable the site before restarting Apache 2.2:
For every entry you want to enable as a VirtualHost file:
/etc/apache2/sites-available/
joe joomla schoo forrest store publisher studios drupal graphics wordpress
All virtualhosts are enabled/disabled via a2ensite/a2dissite hostname
To suppress the error
edit httpd.conf in
/etc/apache2/httpd.conf
[empty file in Debian]:Look up is then resolved for all names you add, comment out or disable down the line.
In case you forget: The sole VirtualHost *:80 entry only needs to be within the ports.conf file,
/etc/apache2/ports.conf
Within your VirtualHost entry leave out VirtualHost *:80
Example: virtualhost joe
Setting
ServerName
in httpd.conf did not work for me. I fixed it by settingServerName 127.0.0.1
in/etc/apache2/conf.d/name
.I'm running Ubuntu 12.10 Alpha3 and have
ServerName
defined in both spots.Source: http://linuxconfig.net/manual-howto/error-solution-could-not-reliably-determine-the-servers-fully-qualified-domain-name.html
You're missing a server configuration-level ServerName entry. You need to have a ServerName entry outside of any host, for Apache to use as its default.
Putting a ServerName entry inside a VirtualHost will not fix the problem. See ServerName Directive.
To fix it, we need to edit the /etc/apache2/httpd.conf or /etc/apache2.conf and add the following line:
I believe you need to add
ServerName
for the default virtual host. Since it's not there, it is taking the default IP address. And it's a kind of warning. Your web server will still be functional I guess.you have to add ServerName in your httpd.conf file using following steps
By default
httpd.conf
file will be blank. Now, simply add the following line to the file.Save the file and exit from
gedit
. Finally restart the server.2) Add
Include httpd.conf
at the end ofapache2.conf
If an httpd.conf file doesn't already exist in your etc/apache2 directory after install, then the main apache configuration file, apache2.conf, will not have a reference to it so adding anything to a created httpd.conf will not do anything. You can simply add the line "ServerName hostname" to the apache2.conf file instead.