Can't restart Apache 2
I'm trying to restart my Apache but it doesn't work. This is the error:
Restarting web server apache2
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
I need some help. Thank you
Solution 1:
First of all, I believe the newer versions of Apache do not use httpd.conf or any of that so I'm not going to discuss "httpd" anything.
I believe the right way to make this warning go away is to NOT TOUCH apache2.conf
.
I've read that this file is updated any time apache2 is updated and if you're like me, you don't want things you've already done to get undone. So use a .conf file under /etc/apache2/available-sites/
My installation had a default file... like 000-default.conf
. If yours doesn't you should probably google a2enconf and learn about creating the .conf files and using a2enconf to make the symlinks.
First thing I did was uncomment ServerName and set it to localhost expecting the warning to go away. Alas, the warning was still there.
My warning had the word 'global'. So I realized the line I changed was inside a <VirtualHost>
tag and supposed that wasn't global. I added "ServerName localhost" on the outside of the vhost tag but still in the 000-default.conf file and voila. Problem solved. And I didn't need to touch apache2.conf so I will never have to bugger with this again even when I update and Apache overwrites apache2.conf. I Hope this clarifies some things about the warning. I hate warnings as much as errors. I like everything to function perfectly but also quietly.
Solution 2:
A hostname is called fully qualified when a domain name is appended to it.
servername is not fully qualified, servername.domainname.org is.
When the command hostname
is used to return the hostname of a system, hostname -f
is used to return the fully qualified hostname.
If you run this command on your system and it return nothing, then you may expect this warning in Apache and in some other programs too.
In this case, if you really want to cure to problem, you will have to define /etc/hosts
accordingly :
<your ip> servername.domainname servername
Example, if my IP is 10.1.1.1, my domain example.com and my hostname host1, a minimal /etc/hosts
file would be :
127.0.0.1 localhost.localdomain localhost
10.1.1.1 host1.example.com host1
After this, the command hostname
will return host1 and hostname -f
returns host1.example.com.
By doing so, no need to tell your Apache that your hostname is localhost. No need to modify the main Apache configuration file, so the next time Apache will be updated, you won't loose your setting or have the new config file not merged into the existing one.