My Linux server (Ubuntu) acts both as the http server and mail server.
Now I want to configure the mail server.
In /etc/hostname I have to set the hostname.
My question is, can I have multiple hostnames for the server?

In the DNS I have setup

       A    12.12.12.12
www    A    12.12.12.12
mail   A    12.12.12.12
       MX   mail 10

Can I have this in /etc/hostname?

www.mydomain.com  
mail.mydomain.com?
有帮助吗?

解决方案

You do not need to list the multiple host names in /etc/hostname. You only need to configure DNS to point the individual hostnames to your IP address. You will need to check the documentation for your mail and http servers to configure the individual hostnames there as well.

For http (assuming you are using apache httpd as your web server), you could configure your hostname like this: (adapted from the configuration 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>

Or better yet, leave off the NameVirtualHost line and replace the * with your IP address.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top