How-to: Resolve Apache error “Could not reliably determine the server’s fully qualified domain name” in Linux
You’ve encountered the message shown below (yes, it’s just a message and not really an error) and have been searching all over the web for a solution that just works, in order to help you get rid of this very annoying message.
Well, guess what? I’m positive that your search ends right here, so go ahead and follow our instructions and you’ll be on your way to success.
Okay, so the first thing you want to do is to check the contents of your “hostname” file using the following command:
sudo nano /etc/hostname
Once the file is opened in your text editor (I like to use “nano”) make a note of the hostname that’s listed there (see screenshot below) and then close the file (without making/saving any changes). Using nano you can close the file by pressing [Ctrl] and [X] and then pressing [N].
The next thing you want to do is to open up the “httpd.conf” file as follows:
sudo nano /etc/apache2/httpd.conf
In all probability this file will be empty when you first open it up. So go ahead and type in the following:
Remember to type in the host name exactly as it was listed in the “/etc/hostname” file i.e. case-sensitivity is important (see below for format/syntax). Save the file by pressing [Ctrl] and [X] followed by [Y] and [Enter].
Now, most sites out there suggest making just the above two changes and then restarting the Apache webserver, but I’m sure that you (just like me) might have found that that just does not work, and in spite of making the above changes, you still continue to receive the message.
Well, I’ve found that this next step is really the one that “puts this issue to bed, once and for all”.
So, go ahead and open up your “apache2.conf” file (using the command shown below) and once again add the above statement (ServerName the-hostname-you-noted-above) to the very end of this file as well:
sudo nano /etc/apache2/apache2.conf
Your file should like similar to the one below:
Save the file (apache2.conf) and then restart your webserver using the following command:
sudo /etc/init.d/apache2 restart
You should now notice that you do not receive the message (when the webserver is restarted).
Another thing you might want to check (using the command shown below) is your “hosts” file, to ensure that it has a reference to your hostname against the IP address 127.0.1.1:
sudo nano /etc/hosts
The contents of your (hosts) files should look similar to the one shown below:
Voila! All Done!
Do write and let us know if this worked well for you and/or if this post was helpful to you in any way.