无法可靠地确定服务器的完全限定域名,使用127.0.0.1作为ServerName。

时间:2023-01-02 20:24:26

I tried to restart my Apache server on CentOS 5.0 and got this message:

我试着在CentOS 5.0重启我的Apache服务器,并得到了这个消息:

httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

无法可靠地确定服务器的完全限定域名,使用127.0.0.1作为ServerName。

Here is the /etc/hosts file:

这里是/etc/hosts文件:

127.0.0.1    server4-245    server4-245.com    localhost.localdomain localhost
::1        localhost6.localdomain6 localhost6

Here is the /etc/sysconfig/network file:

这里是/etc/sysconfig/network文件:

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=server4-245

I also have this in the Apache httpd.conf file:

我在Apache httpd中也有这个。配置文件:

ServerName localhost

However, I still get the first error message when I restart Apache.

但是,当我重新启动Apache时,仍然会收到第一个错误消息。

10 个解决方案

#1


79  

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:

您的主机文件不包含有效的FQDN,本地主机也不包含FQDN。一个FQDN必须包含一个主机名部分,以及一个域名部分。例如,以下是一个有效的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.

选择一个FQDN,并将它包含在您正在使用的IPv4和IPv6地址的/etc/hosts文件中(在您的情况中,localhost或127.0.0.1),并将您的服务器名更改为httpd配置以匹配。

/etc/hosts:

/ etc / hosts:

127.0.0.1    localhost.localdomain localhost host.server4-245.com
::1          localhost.localdomain localhost host.server4-245.com

httpd.conf:

httpd . conf。

ServerName host.server4-245.com

#2


195  

If you don't have httpd.conf in folder /etc/apache2, you should have apache2.conf - simply add:

如果没有httpd。conf在文件夹/etc/apache2中,应该有apache2。conf -只需添加:

ServerName localhost

ServerName localhost

Then restart the apache2 service.

然后重新启动apache2服务。

#3


59  

After the initial install of Apache server, I got the following error while restarting the Apache service on Ubuntu 12.04 (Precise Pangolin)

在Apache服务器的初始安装之后,我在Ubuntu 12.04(确切的穿山甲)重新启动Apache服务时犯了以下错误

The solution is really simple. Just add the ServerName directive to /etc/apache2/httpd.conf:

解决方法非常简单。只需将ServerName指令添加到/etc/apache2/httpd.conf:

sudo nano /etc/apache2/httpd.conf

Add: ServerName localhost

添加:ServerName localhost

Finally restart the Apache server:

最后重新启动Apache服务器:

sudo /etc/init.d/apache2 restart

#4


10  

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:

假设我的服务器是myserver.myhome.com,我的静态IP地址是192.168.1.150:

  1. 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
    
  2. Edit httpd.conf

    编辑httpd . conf

    $ sudo nano -w /etc/apache2/httpd.conf
    
    ServerName myserver.myhome.com
    
  3. Edit network

    编辑网络

    $ sudo nano -w /etc/sysconfig/network HOSTNAME=myserver.myhome.com
    
  4. Verify

    验证

    $ hostname
    
    (output) myserver.myhome.com
    
    $ hostname -f
    
    (output) myserver.myhome.com
    
  5. Restart Apache

    重新启动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.

在主机文件中,出现了不同的情况,包括myserver.myhome.com和静态IP地址192.168.1.150。Ubuntu服务器和CentOS也一样。

#5


8  

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.

在httpd。相依,搜索“ServerName”。它通常会在Mac的默认状态下被注释掉,只是取消注释并填充它。确保在/etc/hosts中设置了名称/ip组合。

#6


3  

In the Apache httpd.conf file:

在Apache httpd。配置文件:

ServerName: 127.0.0.1

#7


2  

There are two ways to resolve this error:

有两种方法可以解决这个错误:

  1. Include /etc/apache2/httpd.conf

    包括/etc/apache2/httpd.conf

    Add the above line in file /etc/apache2/apache2.conf

    将上述行添加到文件/etc/apache2/apache2.conf中。

  2. Add this line at the end of the file /etc/apache2/apache2.conf:

    在文件/etc/apache2/apache2.conf的末尾添加这一行:

    ServerName localhost

    ServerName localhost

#8


0  

I've resolved the fully qualified domain name message on different occasions by adding my server hostname to the /etc/apache2/httpd.conf file and to the /etc/apache2/apache2.conf file.

在不同的场合,我通过将我的服务器主机名添加到/etc/apache2/httpd中,解决了完全限定的域名消息。conf文件和/etc/apache2/apache2。conf文件。

Type hostname -f in your terminal. This query will return your hostname.

在终端中键入主机名-f。此查询将返回您的主机名。

Then edit the /etc/apache2/httpd.conf file (or create it if it does not exist for some reason) and add ServerName <your_hostname>.

然后编辑/etc/apache2/httpd.conf文件(或者创建它,如果它不存在的话),并添加ServerName

Alternatively, I have also been able to eliminate the message by adding ServerName <your_hostname> to the /etc/apache2/apache2.conf file.

另外,我还可以通过在/etc/apache2/apache2上添加ServerName 来消除消息。conf文件。

If all goes well, when you restart Apache, the message will be gone.

如果一切顺利,当您重新启动Apache时,消息将会消失。

#9


0  

Most answers suggest to just add ServerName localhost to /etc/apache2/apache2.conf.

大多数答案建议只添加ServerName localhost到/etc/apache2/apache2.conf。

But quoting Apache documentation :

但是引用Apache文档:

The presence of this error message also indicates that Apache httpd was unable to obtain a fully-qualified hostname by doing a reverse lookup on your server's IP address. While the above instructions will get rid of the warning in any case, it is also a good idea to fix your name resolution so that this reverse mapping works.

此错误消息的存在还表明,Apache httpd无法通过在服务器的IP地址上进行反向查找获得完全限定的主机名。尽管上面的说明将会在任何情况下消除警告,但是修正您的名称解析也不失为一个好主意,以便使这个反向映射起作用。

Therefore adding such a line to /etc/hosts is probably a more robust solution :

因此,向/etc/hosts添加这样的一行可能是一个更健壮的解决方案:

192.0.2.0  foobar.example.com  foobar

where 192.0.2.0 is the static IP address of the server named foobar within the example.com domain.

其中192.0.2.0是example.com域中名为foobar的服务器的静态IP地址。

One can check the FQDN e.g. with

一个可以检查FQDN。

hostname -A

(shortcut for hostname --all-fqdn).

(主机名——all-fqdn快捷方式)。

#10


0  

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).

确保你编辑的是正确的httpd。conf文件,那么关于不可靠服务器的域名的错误应该消失(这是最常见的错误)。

To locate your httpd.conf Apache configuration file, run:

定位你的httpd。Apache配置文件,运行:

apachectl -t -D DUMP_INCLUDES

Then edit the file and uncomment or change ServerName line into:

然后编辑文件,取消注释或将ServerName行更改为:

ServerName localhost

Then restart your apache by: sudo apachectl restart

然后重新启动您的apache: sudo apachectl重新启动。

#1


79  

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:

您的主机文件不包含有效的FQDN,本地主机也不包含FQDN。一个FQDN必须包含一个主机名部分,以及一个域名部分。例如,以下是一个有效的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.

选择一个FQDN,并将它包含在您正在使用的IPv4和IPv6地址的/etc/hosts文件中(在您的情况中,localhost或127.0.0.1),并将您的服务器名更改为httpd配置以匹配。

/etc/hosts:

/ etc / hosts:

127.0.0.1    localhost.localdomain localhost host.server4-245.com
::1          localhost.localdomain localhost host.server4-245.com

httpd.conf:

httpd . conf。

ServerName host.server4-245.com

#2


195  

If you don't have httpd.conf in folder /etc/apache2, you should have apache2.conf - simply add:

如果没有httpd。conf在文件夹/etc/apache2中,应该有apache2。conf -只需添加:

ServerName localhost

ServerName localhost

Then restart the apache2 service.

然后重新启动apache2服务。

#3


59  

After the initial install of Apache server, I got the following error while restarting the Apache service on Ubuntu 12.04 (Precise Pangolin)

在Apache服务器的初始安装之后,我在Ubuntu 12.04(确切的穿山甲)重新启动Apache服务时犯了以下错误

The solution is really simple. Just add the ServerName directive to /etc/apache2/httpd.conf:

解决方法非常简单。只需将ServerName指令添加到/etc/apache2/httpd.conf:

sudo nano /etc/apache2/httpd.conf

Add: ServerName localhost

添加:ServerName localhost

Finally restart the Apache server:

最后重新启动Apache服务器:

sudo /etc/init.d/apache2 restart

#4


10  

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:

假设我的服务器是myserver.myhome.com,我的静态IP地址是192.168.1.150:

  1. 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
    
  2. Edit httpd.conf

    编辑httpd . conf

    $ sudo nano -w /etc/apache2/httpd.conf
    
    ServerName myserver.myhome.com
    
  3. Edit network

    编辑网络

    $ sudo nano -w /etc/sysconfig/network HOSTNAME=myserver.myhome.com
    
  4. Verify

    验证

    $ hostname
    
    (output) myserver.myhome.com
    
    $ hostname -f
    
    (output) myserver.myhome.com
    
  5. Restart Apache

    重新启动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.

在主机文件中,出现了不同的情况,包括myserver.myhome.com和静态IP地址192.168.1.150。Ubuntu服务器和CentOS也一样。

#5


8  

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.

在httpd。相依,搜索“ServerName”。它通常会在Mac的默认状态下被注释掉,只是取消注释并填充它。确保在/etc/hosts中设置了名称/ip组合。

#6


3  

In the Apache httpd.conf file:

在Apache httpd。配置文件:

ServerName: 127.0.0.1

#7


2  

There are two ways to resolve this error:

有两种方法可以解决这个错误:

  1. Include /etc/apache2/httpd.conf

    包括/etc/apache2/httpd.conf

    Add the above line in file /etc/apache2/apache2.conf

    将上述行添加到文件/etc/apache2/apache2.conf中。

  2. Add this line at the end of the file /etc/apache2/apache2.conf:

    在文件/etc/apache2/apache2.conf的末尾添加这一行:

    ServerName localhost

    ServerName localhost

#8


0  

I've resolved the fully qualified domain name message on different occasions by adding my server hostname to the /etc/apache2/httpd.conf file and to the /etc/apache2/apache2.conf file.

在不同的场合,我通过将我的服务器主机名添加到/etc/apache2/httpd中,解决了完全限定的域名消息。conf文件和/etc/apache2/apache2。conf文件。

Type hostname -f in your terminal. This query will return your hostname.

在终端中键入主机名-f。此查询将返回您的主机名。

Then edit the /etc/apache2/httpd.conf file (or create it if it does not exist for some reason) and add ServerName <your_hostname>.

然后编辑/etc/apache2/httpd.conf文件(或者创建它,如果它不存在的话),并添加ServerName

Alternatively, I have also been able to eliminate the message by adding ServerName <your_hostname> to the /etc/apache2/apache2.conf file.

另外,我还可以通过在/etc/apache2/apache2上添加ServerName 来消除消息。conf文件。

If all goes well, when you restart Apache, the message will be gone.

如果一切顺利,当您重新启动Apache时,消息将会消失。

#9


0  

Most answers suggest to just add ServerName localhost to /etc/apache2/apache2.conf.

大多数答案建议只添加ServerName localhost到/etc/apache2/apache2.conf。

But quoting Apache documentation :

但是引用Apache文档:

The presence of this error message also indicates that Apache httpd was unable to obtain a fully-qualified hostname by doing a reverse lookup on your server's IP address. While the above instructions will get rid of the warning in any case, it is also a good idea to fix your name resolution so that this reverse mapping works.

此错误消息的存在还表明,Apache httpd无法通过在服务器的IP地址上进行反向查找获得完全限定的主机名。尽管上面的说明将会在任何情况下消除警告,但是修正您的名称解析也不失为一个好主意,以便使这个反向映射起作用。

Therefore adding such a line to /etc/hosts is probably a more robust solution :

因此,向/etc/hosts添加这样的一行可能是一个更健壮的解决方案:

192.0.2.0  foobar.example.com  foobar

where 192.0.2.0 is the static IP address of the server named foobar within the example.com domain.

其中192.0.2.0是example.com域中名为foobar的服务器的静态IP地址。

One can check the FQDN e.g. with

一个可以检查FQDN。

hostname -A

(shortcut for hostname --all-fqdn).

(主机名——all-fqdn快捷方式)。

#10


0  

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).

确保你编辑的是正确的httpd。conf文件,那么关于不可靠服务器的域名的错误应该消失(这是最常见的错误)。

To locate your httpd.conf Apache configuration file, run:

定位你的httpd。Apache配置文件,运行:

apachectl -t -D DUMP_INCLUDES

Then edit the file and uncomment or change ServerName line into:

然后编辑文件,取消注释或将ServerName行更改为:

ServerName localhost

Then restart your apache by: sudo apachectl restart

然后重新启动您的apache: sudo apachectl重新启动。