Setting up the hostname at ubuntu so that apache does not complain about server's domain name

When setting up LAMP on ubuntu 8.04 I noticed that apache was producing this warning when started:

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

After some googling I found out the way to setup the machines hostname so that apache does not produce this warning.

Set the machine’s hostname to that resolved to its ip and edit /etc/hosts file and make it look like this:

127.0.0.1                    localhost.localdomain localhost
[ethernet interface ip]   [full hostname with the domain] [hostname]

# The following lines are desirable for IPv6 capable hosts
[ipv6 related lines - leave unchanged]

eg. if your ip is 1.2.3.4 and the domain name for this ip is mypc.example.com you have to set your hostmname to mypc and edit /etc/hosts like this:

127.0.0.1     localhost.localdomain localhost
1.2.3.4        mypc.example.com mypc

# 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