无法可靠地确定服务器的完全限定域名

时间:2022-02-14 07:59:17

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

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.

问题是:我在控制台中得到这个错误,Apache无法找到我的localhost,但确实可以启动。奇怪。

[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

所以通常这将指向我的ServerName没有被正确设置。是的,我尝试过像魔影这样的变体。本地主机等

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

这是我的/private/etc/httpd的副本。conf &这与/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

在我的私人/ etc /输入/用户/助教。配置如下

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
# DEV: THEMILL SITE
<VirtualHost *:80>
  ServerAdmin test@dummy.com
  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 test@dummy.com
  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.

不确定还应该配置什么。它曾经是有用的,但发布了10.7升级,它从来没有工作,现在我正试图解决它,它在我的头脑。

Let me know if you need more info.

如果你需要更多的信息,请告诉我。

3 个解决方案

#1


8  

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.

忽略所有关于设置服务器名的建议。这是在转移注意力。Apache正在尝试使用标准的系统组件来确定FQDN,但没有找到任何合适的方法。当然,您可以通过向Apache添加一个全局指令来破坏这个过程,但我认为这是在治疗症状。当然,在虚拟主机块中应该有ServerName指令。

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:

相反,编辑您的主机文件,并确保其中列出了一个FQDN。我看到了关于特定127* line的语法的各种建议,但我认为,只要列出FQDN,什么顺序都没有关系:

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.

这对我很有效,而且似乎比其他所有的“为我工作”都更重要。conf等。我希望这能有所帮助,我不会被否决。如果你不同意,请举例说明原因。谢谢。

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

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.

一旦Apache能够确定系统的FQDN,它将为您的NameBasedHosts读取特定的服务器名指令。

#2


4  

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

您的httpd中的以下行。配置文件是正确的:

ServerName localhost

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

问题是在macOS上它是错误的文件(不是/private/etc/httpd.conf)。

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

查找您的httpd的正确位置。conf Apache配置文件,运行:

apachectl -t -D DUMP_INCLUDES

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

然后再检查ServerName是否未被注释并设置为localhost。

#3


1  

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.

我最近在mac上遇到了同样的问题,尽管我确实编辑了我的主机文件,就像Spanky建议的那样(我认为这也是必要的),我还需要编辑我的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 your@email.com line

在你/etc/apache2/httpd.conf在ServerAdmin your@email.com行之后添加这一行

ServerName your-favorite-server-name

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

来源:https://blog.cloudtroopers.com/upgrade osx - 1010 -优胜美地-和-让- apache -功能

#1


8  

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.

忽略所有关于设置服务器名的建议。这是在转移注意力。Apache正在尝试使用标准的系统组件来确定FQDN,但没有找到任何合适的方法。当然,您可以通过向Apache添加一个全局指令来破坏这个过程,但我认为这是在治疗症状。当然,在虚拟主机块中应该有ServerName指令。

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:

相反,编辑您的主机文件,并确保其中列出了一个FQDN。我看到了关于特定127* line的语法的各种建议,但我认为,只要列出FQDN,什么顺序都没有关系:

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.

这对我很有效,而且似乎比其他所有的“为我工作”都更重要。conf等。我希望这能有所帮助,我不会被否决。如果你不同意,请举例说明原因。谢谢。

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

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.

一旦Apache能够确定系统的FQDN,它将为您的NameBasedHosts读取特定的服务器名指令。

#2


4  

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

您的httpd中的以下行。配置文件是正确的:

ServerName localhost

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

问题是在macOS上它是错误的文件(不是/private/etc/httpd.conf)。

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

查找您的httpd的正确位置。conf Apache配置文件,运行:

apachectl -t -D DUMP_INCLUDES

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

然后再检查ServerName是否未被注释并设置为localhost。

#3


1  

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.

我最近在mac上遇到了同样的问题,尽管我确实编辑了我的主机文件,就像Spanky建议的那样(我认为这也是必要的),我还需要编辑我的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 your@email.com line

在你/etc/apache2/httpd.conf在ServerAdmin your@email.com行之后添加这一行

ServerName your-favorite-server-name

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

来源:https://blog.cloudtroopers.com/upgrade osx - 1010 -优胜美地-和-让- apache -功能