【问题标题】:How do I set up my hosts and httpd.conf files using a static IP address如何使用静态 IP 地址设置我的主机和 httpd.conf 文件
【发布时间】:2012-10-02 13:03:26
【问题描述】:

我在 Rackspace 机器上设置 Centos 6.3,使用静态 IP 地址(不是 FQDN)。我将在这个盒子上设置虚拟主机,它似乎工作正常,但是当我重新启动 HTTPD 服务器时,我收到一条错误消息“无法可靠地确定服务器的完全限定域名,使用 xx.xxx.xx .xx for ServerName”(xx.xxx.xx.xx 是服务器的静态 IP 地址)。

我的 /etc/hosts 中有以下内容:

27.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
xx.xxx.xx.xx    name-used-for-rackspace

name-used-for-racspace 是我创建服务器时使用的名称(不是 FQDN)(您必须输入名称)。

我假设我可能不需要更改 /etc/hosts 中的任何内容,但我应该在 httpd.conf 中添加什么?现在,我在该文件中有以下内容:

NameVirtualHost *:80
<VirtualHost *:80>
    DocumentRoot /var/www/html
    ServerName localhost 
    <Directory /var/www/html>
            allow from all
            Options +Indexes
    </Directory>
</VirtualHost>

我也尝试将 ServerName 设置为 xx.xxx.xx.xx,但我收到了相同的错误消息。

【问题讨论】:

    标签: linux apache centos


    【解决方案1】:

    此错误是因为您没有使用 FQDN。它应该不会影响网络服务器的运行。

    要消除启动时的消息,您需要使用正确的域和 IP 地址配置主机文件。您的 httpd.conf 也应该使用相同的名称(您已指定 localhost)。

    只要您的服务器正在启动并且您不打算为您的网络服务器分配域,就可以忽略此错误。

    具有 FQDN 的虚拟主机示例:

    <VirtualHost *:80>
    ServerName www.domain.net
    ServerAlias domain.net *.domain.net
    ServerAdmin administrator@domain.net
    DocumentRoot "/home/domain/htdocs"
    <Directory "/home/domain/htdocs">
            Options Indexes FollowSymLinks
            AllowOverride All
            Order allow,deny
            Allow from all
    </Directory>
    CustomLog "/home/domain/logs/access-www.log" common
    ErrorLog "/home/domain/logs/error-www.log"
    
            <IfModule mpm_peruser_module>
              ServerEnvironment apache apache
            </IfModule>
    </VirtualHost>
    

    主机文件示例:

    127.0.0.1       localhost       localhost.localdomain gentoo1
    x.x.x.x         gentoo1.domain.net
    

    【讨论】:

    【解决方案2】:

    您需要使用静态 IP 配置网络连接,请参阅下面的参考。否则,您的网络服务器正在工作,但无法从外部访问。

    https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/sec-Configuring_IPv4_Settings.html

    然后把静态IP放在httpd.conf中服务器名后面。

    【讨论】:

    • 您可能应该阅读迄今为止的问题和答案/cmets。你的回答没有解决这个问题。我已经在 httpd.conf 中有静态 IP 地址,我可以在外部正常访问它。我有几个使用 FQDN 的虚拟主机,它们运行良好。问题是我如何摆脱有关主服务器缺少 FQDN 的警告消息。答案是没办法。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-27
    • 2020-10-21
    • 1970-01-01
    • 2022-11-22
    • 2015-11-03
    • 2019-06-21
    • 1970-01-01
    相关资源
    最近更新 更多