httpd: Could not reliably determine the server's fully qualified domain name [closed]
Asked Answered
B

5

18

I know this question's been looked at a lot, but the solutions here aren't solving them.

Let's start with a bit of background info:

OS X 10.8.4 Apache 2.2.22

The problem: I get this error in the console and Apache can't find my localhost, but does start ok. Weird.

[Sat Aug 17 13:40:06 2013] [info] mod_ssl/2.2.22 compiled against Server: Apache/2.2.22, Library: OpenSSL/0.9.8r
httpd: Could not reliably determine the server's fully qualified domain name, using Specter.local for ServerName

So normally this would point to my ServerName not being set right. Well it is :/ and I've tried with different variants like Specter.local, localhost, etc

Here's a copy of my /private/etc/httpd.conf & this is the same for /private/etc/apache2/httpd.conf

# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName localhost

My host file is setup as follows:

127.0.0.1   localhost localhost.local
255.255.255.255 broadcasthost
127.0.0.1       themill.dev
127.0.0.1       phpmyadmin.dev
127.0.0.1       Specter.local

In my /private/etc/apache2/users/ta.conf is the following

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
# DEV: THEMILL SITE
<VirtualHost *:80>
  ServerAdmin [email protected]
  DocumentRoot "/Users/ta/Sites/themill/htdocs"
  ServerName themill.dev
  ServerAlias *.themill.dev
  ErrorLog "/Users/ta/Sites/themill/log/error_log"
  CustomLog "/Users/ta/Sites/themill/log/access_log" common
</VirtualHost>

# PHPMYADMIN
<VirtualHost *:80>
  ServerAdmin [email protected]
  DocumentRoot "/Users/ta/Sites/phpmyadmin"
  ServerName phpmyadmin.dev
  ServerAlias *.phpmyadmin.dev 
  ErrorLog "/Users/ta/Sites/phpmyadmin/log/error_log"
  CustomLog "/Users/ta/Sites/phpmyadmin/log/access_log" common
</VirtualHost>

Not sure what else should be configured really. It used to work but post the 10.7 upgrade, it's never worked and now that I'm trying to solve it it's doing my head in.

Let me know if you need more info.

Brakesman answered 17/8, 2013 at 15:58 Comment(2)
The code that issues that message only runs when the global configuration has no servername, are you sure those configuration files are in use?Naman
I voted to close this question because it is not a programming question. This question is asked and answered on Server Fault apache2: Could not reliably determine the server's fully qualified domain name.Mercurialism
S
9

Ignore ALL of the advice about setting ServerNames. IMHO this is a red herring. Apache is trying to use standard system components to determine a FQDN and not finding anything suitable. Sure, you could subvert this process by adding a directive globally to Apache, but methinks this is treating the symptom. You should have ServerName directives in your virtualhost blocks, of course.

Instead, edit your hosts file and be sure that you have a FQDN listed there. I have seen various suggestions on the syntax for the particular 127* line, but I think that it doesn't matter what order things are in, so long as there is a FQDN listed:

127.0.0.1       localhost.localdomain   localhost       foo.example.com

This worked for me and seemed much more to the point than all of the other "worked for me!" upvotes on posts recommending you edit httpd.conf and such. I hope this helps and that I don't get downvoted. If you disagree, please state why with examples. Thanks.

http://wiki.apache.org/httpd/CouldNotDetermineServerName

Once Apache can determine the system's FQDN, it will then read your specific ServerName directives for your NameBasedHosts.

Shetler answered 24/9, 2013 at 23:14 Comment(1)
"be sure that you have a FQDN listed there" - I have seen this in many answers to this question. By Fully Qualified Domain Name, do you mean I can actually use foo.example.com or does the domain here have to be an actual domain? I never understand if foo.example.com means 'your actual bought and owned domain name here' or specifically 'put any domain name here which follows the FQDN pattern i.e. www.mynonexistentdomain.com'. Could someone provide clarity?Islam
S
35

The following line in your httpd.conf file is correct:

ServerName localhost

The problem is that on macOS it is the wrong file (not /private/etc/httpd.conf).

To find the right location of your httpd.conf Apache configuration file, run:

apachectl -t -D DUMP_INCLUDES

then double check whether ServerName is uncommented and set to localhost.

Subalpine answered 4/12, 2017 at 15:17 Comment(2)
saved mine too, thank you! Only with that command I was able to find correct conf file with an error, default logs are sucks.Allcot
Awesome - the DUMP_INCLUDES line is exactly what I needed, thanks!Sooth
S
9

Ignore ALL of the advice about setting ServerNames. IMHO this is a red herring. Apache is trying to use standard system components to determine a FQDN and not finding anything suitable. Sure, you could subvert this process by adding a directive globally to Apache, but methinks this is treating the symptom. You should have ServerName directives in your virtualhost blocks, of course.

Instead, edit your hosts file and be sure that you have a FQDN listed there. I have seen various suggestions on the syntax for the particular 127* line, but I think that it doesn't matter what order things are in, so long as there is a FQDN listed:

127.0.0.1       localhost.localdomain   localhost       foo.example.com

This worked for me and seemed much more to the point than all of the other "worked for me!" upvotes on posts recommending you edit httpd.conf and such. I hope this helps and that I don't get downvoted. If you disagree, please state why with examples. Thanks.

http://wiki.apache.org/httpd/CouldNotDetermineServerName

Once Apache can determine the system's FQDN, it will then read your specific ServerName directives for your NameBasedHosts.

Shetler answered 24/9, 2013 at 23:14 Comment(1)
"be sure that you have a FQDN listed there" - I have seen this in many answers to this question. By Fully Qualified Domain Name, do you mean I can actually use foo.example.com or does the domain here have to be an actual domain? I never understand if foo.example.com means 'your actual bought and owned domain name here' or specifically 'put any domain name here which follows the FQDN pattern i.e. www.mynonexistentdomain.com'. Could someone provide clarity?Islam
W
5

You need to Set the 'ServerName' directive globally to suppress this message.

  1. The first step is to find the actual apache configuration file because chances are that you are editing the wrong file

find your httpd.conf Apache configuration file for example by this command:

apachectl -t -D DUMP_INCLUDES

For example: /usr/local/etc/httpd/httpd.conf.

then edit it and uncomment the line with ServerName (make sure it has the valid server name). E.g.

ServerName localhost

You can thank me later!

Wilma answered 4/8, 2020 at 21:24 Comment(0)
H
2

I recently had the same problem on a mac and though I did edit my host file as Spanky suggests (and I think this is also necessary), I also needed to edit my httpd.conf.

in case anyone has this in the future the following may work

in your /etc/apache2/httpd.conf add this line after the ServerAdmin [email protected] line

ServerName your-favorite-server-name

source: https://blog.cloudtroopers.com/upgrade-osx-1010-yosemite-and-keep-apache-functional

Habergeon answered 21/7, 2016 at 16:13 Comment(0)
A
1

I had a few problems en-route to glory, some self-created. As a rule of thumb I found that simply running: $sudo httpd -k restart got me one step further each time by virtue of the messages output.

Artemisia answered 9/8, 2018 at 11:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.