httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
I tried to restart my Apache server on CentOS 5.0 and got this message:
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
Here is the /etc/hosts
file:
127.0.0.1 server4-245 server4-245.com localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
Here is the /etc/sysconfig/network
file:
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=server4-245
I also have this in the Apache httpd.conf file:
ServerName localhost
However, I still get the first error message when I restart Apache.
If you don't have httpd.conf
in folder /etc/apache2
, you should have apache2.conf - simply add:
ServerName localhost
Then restart the apache2
service.
Your hosts file does not include a valid FQDN, nor is localhost
an FQDN. An FQDN must include a hostname part, as well as a domain name part. For example, the following is a valid FQDN:
host.server4-245.com
Choose an FQDN and include it both in your /etc/hosts
file on both the IPv4 and IPv6 addresses you are using (in your case, localhost
or 127.0.0.1
), and change your ServerName
in your httpd configuration to match.
/etc/hosts:
127.0.0.1 localhost.localdomain localhost host.server4-245.com
::1 localhost.localdomain localhost host.server4-245.com
httpd.conf:
ServerName host.server4-245.com
After the initial install of Apache server, I got the following error while restarting the Apache service on Ubuntu 12.04 (Precise Pangolin)
The solution is really simple. Just add the ServerName
directive to /etc/apache2/httpd.conf
:
sudo nano /etc/apache2/httpd.conf
Add: ServerName localhost
Finally restart the Apache server:
sudo /etc/init.d/apache2 restart
Make sure you're editing the right httpd.conf
file, then the error about unreliable server's domain name should be gone (this is the most common mistake).
To locate your httpd.conf
Apache configuration file, run:
apachectl -t -D DUMP_INCLUDES
Then edit the file and uncomment or change ServerName
line into:
ServerName localhost
Then restart your apache by: sudo apachectl restart