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,
If you've edited /etc/apache2/httpd.conf
with the ServerName localhost
you may be editing the wrong file. All answers I found were pointing towards that standard httpd.conf. After some foraging, I found a good answer here.
To locate the right httpd.conf file use
apachectl -t -D DUMP_INCLUDES
I found mine was actually /usr/local/etc/httpd/httpd.conf
.
Use your preferred editor to comment out the line (i.e. remove the #
before) starting with ServerName, and replace the domain name for the appropriate one – local environments should work with
ServerName localhost
I hope this helps more people who may be stuck.
Turns out that I had this problem and it was because I used "tabs" to indent lines instead of spaces. Just posting, in case it helps anyone.
In the Apache httpd.conf
file:
ServerName: 127.0.0.1
So while this is answered and accepted it still came up as a top search result and the answers though laid out (after lots of research) left me scratching my head and digging a lot further. So here's a quick layout of how I resolved the issue.
Assuming my server is myserver.myhome.com and my static IP address is 192.168.1.150:
Edit the hosts file
$ sudo nano -w /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
127.0.0.1 myserver.myhome.com myserver
192.168.1.150 myserver.myhome.com myserver
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
::1 myserver.myhome.com myserver
Edit httpd.conf
$ sudo nano -w /etc/apache2/httpd.conf
ServerName myserver.myhome.com
Edit network
$ sudo nano -w /etc/sysconfig/network HOSTNAME=myserver.myhome.com
Verify
$ hostname
(output) myserver.myhome.com
$ hostname -f
(output) myserver.myhome.com
Restart Apache
$ sudo /etc/init.d/apache2 restart
It appeared the difference was including myserver.myhome.com
to both the 127.0.0.1 as well as the static IP address 192.168.1.150 in the hosts file. The same on Ubuntu Server and CentOS.
There are two ways to resolve this error:
Include /etc/apache2/httpd.conf
Add the above line in file /etc/apache2/apache2.conf
Add this line at the end of the file /etc/apache2/apache2.conf:
ServerName localhost
In httpd.conf, search for "ServerName". It's usually commented out by default on Mac. Just uncomment it and fill it in. Make sure you also have the name/ip combo set in /etc/hosts.