我想使用虚拟主机设置一个子域。 我已经修改了httpd.conf文件,如下所示,但当我尝试访问url时,出现“找不到服务器”错误。 我正在运行Centos 5.5。
NameVirtualHost *:80 # # NOTE: NameVirtualHost cannot be used without a port specifier # (eg :80) if mod_ssl is being used, due to the nature of the # SSL protocol. # # # VirtualHost example: # Almost any Apache directive may go into a VirtualHost container. # The first VirtualHost section is used for requests without a known # server name. # #<VirtualHost *:80> # ServerAdmin [email protected] # DocumentRoot /www/docs/dummy-host.example.com # ServerName dummy-host.example.com # ErrorLog logs/dummy-host.example.com-error_log # CustomLog logs/dummy-host.example.com-access_log common #</VirtualHost> <VirtualHost *:80> ServerName www.mydomain.com DocumentRoot /var/www/html/ </VirtualHost> <VirtualHost *:80> DocumentRoot "/var/www/vhosts/test_mydomain_com/" ServerName test.mydomain.com ErrorLog logs/test_mydomain_com-error_log CustomLog logs/test_mydomain_com-access_log common </VirtualHost>
我有:
我很惊讶,即使找不到子域名,它也不会被路由到www.mydomain.com区域,因为这是我认为我将它设置为与第一个虚拟主机语句。
我试图通过访问子域名:
http://test.mydomain.com
我需要做什么(因此了解)的DNS设置,以实现我想在这里? 这是什么可能会出错?
您需要将Alogging或CNAMElogging添加到您的DNS服务器才能正常工作。 听起来像你没有一个。 您可以通过发布host test.mydomain.com来确认我们。
如果你回来:
Host test.mydomain.com not found: 3(NXDOMAIN)
那就是你的问题。
为test.mydomain.com添加Alogging(主机名 – > IP)或CNAME(主机名 – >主机名),您应该开始业务。
如果你得到“服务器没有find”的错误,那么这可能是一个DNS问题,而不是Apache。
你为新的子域创build了一个DNSlogging吗?