添加了新的虚拟主机以重定向外部域名加载第一个虚拟主机

添加了新的虚拟主机以重定向外部域名加载第一个虚拟主机

配置:

<VirtualHost sub.domain.com:80>
        NameVirtualHost sub.domain.com:80
        ServerName sub.domain.com
        DocumentRoot /home/colleague/public_html/domain.com/ZendSkeletonApplication/public/

        SetEnv APPLICATION_ENV "development"

        <Directory /home/colleague/public_html/domain.com/ZendSkeletonApplication/public >
                Options Indexes FollowSymLinks Includes ExecCGI
        DirectoryIndex index.php
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>
<VirtualHost bugtrack.sub.domain.com:80>
        NameVirtualHost bugtrack.sub.domain.com:80
        ServerName bugtrack.sub.domain.com
        DocumentRoot /home/colleague/public_html/bugtrack.sub.domain.com/

        SetEnv APPLICATION_ENV "development"

        <Directory /home/colleague/public_html/bugtrack.sub.domain.com >
                Options Indexes FollowSymLinks Includes ExecCGI
                DirectoryIndex index.php
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>
<VirtualHost domain2:80>
        NameVirtualHost domain2:80
        ServerName  domain2.com
        DocumentRoot /home/me/public_html

        SetEnv APPLICATION_ENV "development"

        <Directory /home/me/public_html >
                Options Indexes FollowSymLinks Includes ExecCGI
        DirectoryIndex index.php
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>

错误:

[Wed Jun 18 18:06:44 2014] [warn] NameVirtualHost bugtrack.sub.domain.com:80 has no VirtualHosts
[Wed Jun 18 18:06:44 2014] [warn] NameVirtualHost domain2.com:80 has no VirtualHosts
[Wed Jun 18 18:06:44 2014] [warn] NameVirtualHost *:80 has no VirtualHosts

如果我访问 domain2.com(虚拟域),我会到达 sub.domain.com 。我认为这是因为其他两个虚拟主机有问题。bugtrack 虚拟主机确实加载了 Bug Genie,但新添加的由第三方注册商托管的第二个域不起作用,并导致第一个虚拟主机。当我在 http conf 中取消注释该行时,出现了最后一个错误,因为我认为这可以解决问题。

我该如何修复这个配置并让 domain2 进入我需要的文档根目录?

答案1

进行虚拟主机定义

<VirtualHost *:80> 

确保你有NameVirtualHost *一个外部您的 VirtualHost 上下文。 名称虚拟主机仅允许在服务器配置中语境例如

NameVirtalHost *
<VirtualHost *:80>
    ServerName sub.domain.com
    DocumentRoot /home/colleague/public_html/domain.com/ZendSkeletonApplication/public/
    ...
</VirtualHost>

相关内容