【问题标题】:How do i set up the server's fully qualified domain name?如何设置服务器的完全限定域名?
【发布时间】:2025-10-07 11:00:01
【问题描述】:

当我尝试重新启动 apache 发出 /etc/init.d/apache2 restart 我收到以下消息:

root@server:~# /etc/init.d/apache2 restart
 * Restarting web server apache2                                                                                                                             apache2: apr_sockaddr_info_get() failed for server
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
 ... waiting apache2: apr_sockaddr_info_get() failed for server
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
                                                                                                                                                      [ OK ]
root@server:~# cat /etc/hostname
iSell
root@server:~# hostname
server
root@server:~# hostname -f
hostname: Name or service not known
root@server:~# cat /etc/hosts
127.0.0.1     localhost localhost.localdomain
108.1.*.*     eins
root@server:~#

注意:/etc/hosts 中 ip 末尾的两个星号是我在发帖时添加的。 注意2:假设我的域名是www.xyz.net

我想确切地知道我必须一步一步地做什么。 非常感谢!

【问题讨论】:

  • 这与编程无关。请考虑在其他 SE 网站上发布。
  • 这种行为只存在于ubuntu中

标签: apache configuration fqdn


【解决方案1】:

将 ServerName 添加到 /etc/apache2/apache.conf

ServerName [yourservername or localhost]

并加载 Apache 配置: service apache2 restart

【讨论】:

    【解决方案2】:
    1. 首先,检查您的 apache 版本
      $ apache2 -v
    2. 如果您的 apache 版本是 2.x,请使用以下命令来避免此消息
      $ echo "ServerName\t`cat /etc/hostname`" | sudo tee -a /etc/apache2/apache2.conf

    【讨论】:

      【解决方案3】:

      1) 编辑文件: vi /etc/apache2/apache.conf 2)在最后一行写(看到你的机器名写:cat /etc/hostname): ServerName 你的机器名 3)服务 apache2 重新加载

      尽情享受吧!

      【讨论】:

        【解决方案4】:

        编辑你的主机文件

        sudo nano /etc/hosts
        

        看看你的ip 127.0.1.1是不是服务器的好名字

        127.0.1.1      srv-web-01
        

        然后重启你的 Apache

        sudo service apache2 restart
        

        【讨论】:

          【解决方案5】:

          只需使用以下内容编辑 Apache 的空白 httpd.conf:

          sudo gedit /etc/apache2/httpd.conf
          

          添加行:

          ServerName localhost
          

          保存并退出并重新启动 Apache:

          sudo /etc/init.d/apache2 restart
          

          这会解决的。

          【讨论】:

          • 关于 Jessie 修复 /etc/apache2/apache2.conf
          最近更新 更多