我的 Linux 服务器 (Ubuntu) 同时充当 http 服务器和邮件服务器。
现在我要配置邮件服务器。
在 /etc/hostname 中,我必须设置主机名。
我的问题是,服务器可以有多个主机名吗?
在我设置的 DNS 中
A 12.12.12.12
www A 12.12.12.12
mail A 12.12.12.12
MX mail 10
我可以在/etc/hostname 中有这个吗?
www.mydomain.com
mail.mydomain.com?
最佳答案
您不需要在/etc/hostname 中列出多个主机名。您只需要配置 DNS 以将各个主机名指向您的 IP 地址。您还需要查看邮件和 HTTP 服务器的文档以配置各个主机名。
对于 http(假设您使用 apache httpd 作为您的 Web 服务器),您可以像这样配置您的主机名:(改编自配置 here )
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.mydomain.com
ServerAlias domain.tld
DocumentRoot /www/domain
</VirtualHost>
<VirtualHost *:80>
ServerName www.otherdomain.com
DocumentRoot /www/otherdomain
</VirtualHost>
或者更好的是,去掉 NameVirtualHost 行并将 * 替换为您的 IP 地址。
关于linux - www 和邮件的 FQDN 主机名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23410435/