更改主机名 - 网站不再可访问

更改主机名 - 网站不再可访问

我运行的是 Centos 7,我将 /etc/hostname “centos-512mb-blr1-01” 更改为 “srv1.domain.com”,然后重新启动以使更改生效,从那时起,我的所有网站都关闭了。我尝试撤消更改。但仍然收到 ERR_CONNECTION_TIMED_OUT

这是我的配置文件:

[root@srv1 ~]# cat /etc/hosts
# The following lines are desirable for IPv4 capable hosts
127.0.0.1 srv1.example.com domain.com
127.0.0.1 example.com
127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost4.localdomain4 localhost4
139.59.57.xx srv1.example.com example.com

# The following lines are desirable for IPv6 capable hosts
::1 srv1.example.com srv1.example.com
127.0.0.1 example.com
::1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
139.59.57.xx example.com example.com


[root@srv1 ~]# cat /etc/hostname
srv1.example.com


[root@srv1 ~]# cat /etc/sysconfig/network
NETWORKING=yes
NOZEROCONF=yes
HOSTNAME=srv1.example.com

请告知我做错了什么。

答案1

您是否还更改了 httpd/nginx/(其他任何配置)的配置?因为如果您在 Web 服务器设置中使用旧主机名,则很可能无法绑定到该地址。

另外,在您的 /etc/hosts 中您svr1.example.com列出了两次:

127.0.0.1 srv1.example.com domain.com
139.59.57.xx srv1.example.com example.com

IPv6 也类似。这也可能会有问题。您应该只列出一个 IP。请尝试将您的 IP 修改/etc/hosts为:

# The following lines are desirable for IPv4 capable hosts
127.0.0.1 localhost.localdomain localhost4.localdomain4 localhost localhost4 domain.com
139.59.57.xx srv1.example.com example.com

# The following lines are desirable for IPv6 capable hosts
::1 localhost.localdomain localhost6.localdomain6 localhost localhost6
139.59.57.xx srv1.example.com example.com

相关内容