Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName

Written by
Date: 2013-01-10 17:50:13 00:00

If Apache2 in Ubuntu gives you this error:

apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName

all you need to do is to add a the variable ServerName to the Apache configuration.

You can add it to apache2.conf at the end of the file.

ServerName localhost

Or if you have a name a name in /etc/hostname you can use it:

ServerName ubuntu

If you prefer not to mess with apache2.conf file, you can create (if it not exist yet) the file /etc/apache2/httpd.conf and add the line there.

sudo sh -c 'echo "ServerName localhost" >> /etc/apache2/conf.d/servername.conf'

According to the documentation of Ubuntu, the file httpd.conf is:

historically the main Apache2 configuration file, named after the httpd daemon. The file can be used for user specific configuration options that globally effect Apache2.

So you are free to use it.

There is yet another option, as in Ubuntu the directory /etc/apache2/conf.d/ is included by default in the Apache configuration, all files you add there will be parsed by Apache and add its contents to the configuration. So, you can create a file there and add the ServerName in that file. Call that file servername.conf, just run this command.

sudo sh -c 'echo "ServerName localhost" >> /etc/apache2/conf.d/servername.conf'

or, as in my case:

sudo sh -c 'echo "ServerName ubuntu" >> /etc/apache2/conf.d/servername.conf'