首先,需要编辑 /etc/hosts 文件,找到含有你的 VPS IP 地址的那一行;如果没有,则添加一行。内容如下:
127.0.0.1 mail.*****.com mail
其中, 127.0.0.1 可换为你的服务器 IP 地址,后面依次填入长主机名和短主机名,切记不可填反。
然后,我们找到 VPS 的 /etc/hostname 文件,编辑里面的内容为 mail (域名的前缀)
这样,就设置好了主机名。重启 VPS后我们检查一下是否设置正确:
执行:hostname
此时我们应该只能看到短主机名 mail. 如果你看到了长主机名 mail.jichang.ml , 说明之前设置错误,请重新检查上述步骤。
执行:hostname -f
此时,我们应该只能看到长主机名 mail.jichang.ml
这样,我们就全部设置好了主机名(hostname), 可以进行接下来的其他操作了
Welcome to Ubuntu 22.04.5 LTS (GNU/Linux 5.15.0-124-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/pro
System information as of Sun Oct 20 03:04:58 AM UTC 2024
System load: 0.25
Usage of /: 33.7% of 9.75GB
Memory usage: 6%
Swap usage: 0%
Processes: 144
Users logged in: 0
IPv4 address for enp0s3: 192.168.1.6
IPv6 address for enp0s3: 2409:8a4c:725c:2710:a00:27ff:fe6c:5547
* Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
just raised the bar for easy, resilient and secure K8s cluster deployment.
https://ubuntu.com/engage/secure-kubernetes-at-the-edge
Expanded Security Maintenance for Applications is not enabled.
12 updates can be applied immediately.
To see these additional updates run: apt list --upgradable
Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status
New release '24.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
Last login: Sun Oct 20 03:04:58 2024
wqbboy@mail:~$ sudo su -
[sudo] password for wqbboy:
root@mail:~# cd /root/iRedMail-1.7.1/
root@mail:~/iRedMail-1.7.1# ls
ChangeLog config Documentations iRedMail.sh pkgs runtime tools
conf dialog functions LICENSE README.md samples update
root@mail:~/iRedMail-1.7.1# hostname
mail
root@mail:~/iRedMail-1.7.1# hostname -f
mail.xgpolice.com
root@mail:~/iRedMail-1.7.1# cat /etc/hostname
mail
root@mail:~/iRedMail-1.7.1# cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 mail.xg****.com mail localhost
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
root@mail:~/iRedMail