如何使用静态IP地址设置主机和httpd.conf文件

时间:2022-03-08 07:15:14

I set Centos 6.3 up on a Rackspace box, using a static IP address (not a FQDN). I will be setting up virtual hosts on this box, and it seems to be working fine, but when I restart the HTTPD server, I get an error message "could not reliably determine the server's fully qualified domain name, using xx.xxx.xx.xx for ServerName" (xx.xxx.xx.xx is the static IP address for the server).

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

My /etc/hosts has the following in it:

我的/ 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 is a name (not a FQDN) I used when I created the server (you have to enter a name).

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

I assume that I may not have to change anything in /etc/hosts, but what do I put in httpd.conf? right now, I have the following in that file:

我假设我可能不需要在/ 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>

I also tried setting ServerName to xx.xxx.xx.xx, but I got the same error message.

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

2 个解决方案

#1


0  

This error is because you are not using a FQDN. It should not affect the operation of the webserver.

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

To get rid of the message on startup you'd need to configure your hosts file with the correct domain and IP address. Your httpd.conf should also use the same name (where you have localhost specified).

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

As long as your server is starting and you don't plan on assigning a domain to your webserver, this error can be ignored.

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

Example virtual host with FQDN:

具有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>

Example hosts file:

示例主机文件:

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

#2


-1  

You need to configure the network connection with your static IP, see reference below. Otherwise, your web server is working, but it's not accessible externally.

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

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

Then put the static IP in the httpd.conf after server name.

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

#1


0  

This error is because you are not using a FQDN. It should not affect the operation of the webserver.

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

To get rid of the message on startup you'd need to configure your hosts file with the correct domain and IP address. Your httpd.conf should also use the same name (where you have localhost specified).

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

As long as your server is starting and you don't plan on assigning a domain to your webserver, this error can be ignored.

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

Example virtual host with FQDN:

具有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>

Example hosts file:

示例主机文件:

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

#2


-1  

You need to configure the network connection with your static IP, see reference below. Otherwise, your web server is working, but it's not accessible externally.

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

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

Then put the static IP in the httpd.conf after server name.

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