腾讯云Centos7服务器修改/etc/hosts
第一次在腾讯云购买了服务器,然后我需要修改/etc/hosts文件测试安装iRedmail邮件服务器,一打开/etc/hosts文件便如以下:
# Your system has configured 'manage_etc_hosts' as True. # As a result, if you wish for changes to this file to persist # then you will need to either # a.) make changes to the master file in /etc/cloud/templates/hosts.redhat.tmpl # b.) change or remove the value of 'manage_etc_hosts' in # /etc/cloud/cloud.cfg or cloud-config from user-data # # The following lines are desirable for IPv4 capable hosts 127.0.0.1 VM_0_12_centos VM_0_12_centos 127.0.0.1 localhost.localdomain localhost 127.0.0.1 localhost4.localdomain4 localhost4 # The following lines are desirable for IPv6 capable hosts ::1 VM_0_12_centos VM_0_12_centos ::1 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6
修改方式和常规的直接修改方式的不一样,直接对/etc/hosts文件进行修改,比如直接添加 127.0.0.1 mail.chenxie.net 到/etc/hosts ,保存后虽然ping mail.chenxie.net可以通,但是iRedmail的安装检测脚本通不过,而且重启系统后添加的记录就消失了。
文件注释说,我的系统配置了manage_etc_hosts为True,如果要修改hosts的话
a. 需要先对/etc/cloud/templates/hosts.redhat.tmpl进行修改,
b. 然后修改或删除manage_etc_hosts的值在/etc/cloud/cloud.cfg文件中。
第一步,修改/etc/cloud/templates/hosts.redhat.tmpl文件:
直接添加你要在/etc/hosts文件中出现的文件内容:
127.0.0.1 mail.chenxie.net
关于第二步,修改manage_etc_hosts的值,在/etc/cloud/cloud.cfg文件中没有找到,那就忘掉吧。
最后reboot重启你的机器生效。
说明:安装iRadMail还要修改主机名,本次没有仔细看文档也吃了点亏,修改/etc/hostname,然后reboot生效。
MutualExclsion
哎呀我去了,咋的?还要重启机器?它怎么不死呢?
👿
gongel
直接在etc/hosts里面加上腾讯云 主机名:内网地址 的映射即可。
匿名
我也是第一次用腾讯云,请教下作者可以加下邮箱或者QQ吗,方便交流