apache没有正确处理子域名虚拟主机窗口

时间:2015-12-06 20:37:00

标签: apache amazon-ec2 virtualhost

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

我在Windows Server 2012上使用PHP 5.6和MySQL运行Apache 2.4。在亚马逊EC2实例上。我拥有所有正确的安全设置,并且我还在路由S3中正确设置了我的dns以指向我的EC2,为我的子域设置了一个条目。主域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是我服务器的公共IP地址。

2 个答案:

答案 0 :(得分:0)

您可以从Apache 2.4 here的虚拟主机示例中阅读“使用ServerPath指令”部分开始(在评论之前的部分)。我现在没有尝试,但我过去曾用过那个页面来解决类似的问题。因为它是Apache我不复制任何内容,因为它可能在未来几年内在同一地址...

答案 1 :(得分:0)

Strangely enough I tried the solution from @Gillsoft AB. And when I tried to restart apache it failed to restart. Then I reverted back to where I was. Then changed each <%= event.eventdate.strftime("%b") %> to <VirtualHost *:80>, rebooted, This didn't work. Then I went back to how it originally was when I first posted, rebooted again. And now it works????