【问题标题】:httpd.conf configuration issuehttpd.conf 配置问题
【发布时间】:2014-08-20 22:18:53
【问题描述】:

我目前正在将一堆网站迁移到 amazon ec2(在 Amazon Linux AMI 上运行),但无法让 Apache 的 VirtualHost 配置正常工作。

这是我的 httpd.conf 文件的样子:

<VirtualHost *:80>
    ServerName example.com
    DocumentRoot /home/sites/example.com/

    <Directory /home/sites/example.com>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>
    ErrorLog /var/log/httpd/example.com.error.log
    LogLevel warn
    CustomLog /var/log/httpd/example.com.access.log combined


</VirtualHost>

<VirtualHost *:80>
        ServerName blog.example.com
        DocumentRoot /home/sites/blog.example.com/

        <Directory /home/sites/blog.example.com>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
        ErrorLog /var/log/httpd/blog.example.com.error.log
        LogLevel warn
        CustomLog /var/log/httpd/blog.example.com.access.log combined
</VirtualHost>

这是httpd -S的结果

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
_default_:443          example.com (/etc/httpd/conf.d/ssl.conf:74)
*:80                   is a NameVirtualHost
         default server example.com (/etc/httpd/conf/httpd.conf:1012)
         port 80 namevhost example.com (/etc/httpd/conf/httpd.conf:1012)
         port 80 namevhost blog.example.com (/etc/httpd/conf/httpd.conf:1029)
Syntax OK

但是,如果我尝试访问 blog.example.com,我会收到 ERR_NAME_NOT_RESOLVED 响应。

如果我将第一个 VirtualHost 定义更改为 blog.example.com,我可以加载 blog.example.com 站点,因此两个站点都可以正常工作,这让我怀疑我在 VirtualHost 中或在我的域名注册商结束。

【问题讨论】:

  • 您的问题可能是 DNS。您有 blog.example.com 的记录吗?
  • 所以我应该有example.com和blog.example.com的A记录,都去同一个IP,对吧?那仍然对我不起作用。
  • 啊,这只是一个顺序问题,站点的域前缀版本需要在 example.com 之前。

标签: apache amazon-ec2 virtualhost


【解决方案1】:

我的问题是我在 blog.example.com 域之前拥有 example.com 域,这意味着所有内容都转到了 example.com。订单很重要!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-30
    • 2019-08-17
    • 2012-02-18
    • 2016-08-08
    • 2019-12-10
    • 2015-08-05
    • 2016-07-28
    相关资源
    最近更新 更多