apache 没有正确处理子域虚拟主机 windows

apache not handling subdomains properly virtual hosts windows

我搜索了很多 post 并在 httpd.conf 中尝试了各种不同的配置方式。

我 运行 Apache 2.4 在 windows 服务器 2012 上 PHP 5.6 和 MySQL。在亚马逊 EC2 实例上。我有所有正确的安全设置,我还在路由 S3 中正确设置了我的 dns 以指向我的 EC2,我的子域有 A 条目。主域 www.mydomain.com 工作正常并指向正确的位置 htdocs。但是我的子域没有映射到我定义如下的文件夹:

NameVirtualHost ip.ip.ip.ip:80      

<VirtualHost *:80>
    ServerName www.mydomain.com
    ServerAlias mydomain.com
    DocumentRoot c:/Apache24/htdocs
    DirectoryIndex index.php index.htm index.html
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot c:/Apache24/htdocs/sub1
    ServerName sub1.mydomain.com
    DirectoryIndex index.php index.htm index.html
    ErrorLog logs/sub1-error.txt
    CustomLog logs/sub1-access.txt common
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot c:/Apache24/htdocs/phpMyAdmin
    ServerName phpmyadmin.mydomain.com
    DirectoryIndex index.php index.htm index.html
    ErrorLog logs/phpmyadmin-error.txt
    CustomLog logs/phpmyadmin-access.txt common
</VirtualHost>

非常感谢所有帮助。

我的 HOSTS 文件中也有这些条目

    ip.ip.ip.ip mydomain.com
ip.ip.ip.ip *.mydomain.com
ip.ip.ip.ip sub1.mydomain.com
ip.ip.ip.ip phpmyadmin.mydomain.com

ip.ip.ip.ip 是我服务器的 public IP 地址。

您可以先阅读 Apache 2.4 here 的虚拟主机示例中的 "Using the ServerPath directive" 部分(最后在评论部分之前)。我现在没有尝试,但我过去曾使用该页面解决过类似问题。由于它是 Apache,我不会复制任何内容,因为它可能在未来几年位于同一地址...

奇怪的是,我尝试了@Gillsoft AB 的解决方案。当我尝试重新启动 apache 时,它​​未能重新启动。然后我回到原来的位置。然后将每个 <VirtualHost *:80> 更改为 <VirtuHost ip.ip.ip.ip:80>,重新启动,这没有用。然后我又回到了最初发布时的状态,再次重新启动。现在可以用了????