未能在Ubuntu上正确configurationApache2子域

我租了一个运行Ubuntu的小型虚拟专用服务器,我试图configuration一个子域。 感谢几个资源,我已经知道我应该如何做到这一点,但仍然没有成功。

希望有人能帮我找出我做错了什么。

我在/etc/apache2/sites-available创build了一个名为<domain>.conf的文件。 它包含以下内容:

 NameVirtualHost *:80 # Configuration for index.<domain> and <domain>. <VirtualHost *:80> ServerAdmin administrator@<domain> DocumentRoot /var/www/sites/<domain>/index ServerName index.<domain> ServerAlias <domain> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> 

我已经使用以下命令启用了该网站:

 sudo a2ensite /etc/apache2/sites-available/<domain>.conf 

此外,我已经configurationDNS设置如下:

 Name Type Value <domain> A <ip-address> index.|DOMAIN| A <ip-address> 

打开http://<domain>工作得很好,但打开http://index.<domain>不会。 相反,我收到一条消息,告诉我“这个网页不可用”。


apache2ctl -S返回以下内容:

 AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message VirtualHost configuration: *:80 is a NameVirtualHost default server localhost (/etc/apache2/sites-enabled/000-default.conf:1) port 80 namevhost localhost (/etc/apache2/sites-enabled/000-default.conf:1) port 80 namevhost index.<domain> (/etc/apache2/sites-enabled/<domain>.conf:4) alias <domain> 

您设置了一个名为“www.domain”的子域名,并为子域“index.domain”添加了一条logging

尝试这个:

在你的虚拟主机configuration中:

 <VirtualHost *:80> ServerAdmin administrator@domain DocumentRoot /var/www/sites/domain/www ServerName domain ServerAlias www.domain ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> 

然后运行:

 apache2ctl -t service apache2 reload 

在您的区域文件中:

 domain. IN A WXYZ www IN CNAME domain. 

然后运行:

 named-checkzone domain /path/to/zone/file/db.domain service bind9 reload 

确保您的子域由您的DNS服务器parsing:

 dig @WXYZ www.domain A +short WXYZ