Fixing Apache 2 “Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName” Error on Raspberry Pi Wheezy

You might probably find this error while starting/restarting Apache web server on Raspberry Pi Wheezy:

root@raspi:# /etc/init.d/apache2 restart
[....] Restarting web server: apache2apache2: 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 error caused by Apache’s ServerName confguration is missing in apache2.conf file. So, as a quick fix to this error is creating or editing a httpd.conf file in directory /etc/apache2/conf.d using nano:

root@raspi:# cd /etc/apache2/conf.d
root@raspi:/etc/apache2/conf.d# nano httpd.conf

Put the following line on httpd.conf file:

ServerName localhost

Save the file using Ctrl+O command, and exit nano using Ctrl+X.

Restart Apache 2 using the following command

root@raspi:/etc/apache2/conf.d# /etc/init.d/apache2 restart
root@raspi:/etc/apache2/conf.d# /etc/init.d/apache2 restart
[ ok ] Restarting web server: apache2 ... waiting .
root@raspi:/etc/apache2/conf.d#

That’s it! The FQDN error has gone, and you are good to go to your awesome Raspberry Pi project. Hope this helps!

Note:
Raspberry Pi Raspbian “Wheezy” is Debian-based Linux OS, so this tutorial might be applicable to other Debian-based OS, such as Ubuntu.