【问题标题】:Apache Showing Default page VHOST PageApache 显示默认页面 VHOST 页面
【发布时间】:2013-10-03 04:12:30
【问题描述】:

我已经通过这样的虚拟主机添加了一些站点,我还指定了他们的文档路径。我在那里添加了所有内容,但由于某种原因,当我通过浏览器访问该站点时,Apache 默认页面出现了。

<VirtualHost *:80>
    ServerAdmin admin@mydomain.com
    DocumentRoot "/var/www/html/mydomain/public_html"
    ServerName mydomain.com
    ServerAlias www.mydomain.com
    ErrorLog "/var/log/httpd/mydomain/error_log"
    CustomLog "/var/log/httpd/mydomain/access_log" common
</VirtualHost>

如果有人知道出了什么问题,请告诉我!

【问题讨论】:

    标签: apache webserver


    【解决方案1】:

    您的服务器名称是 mydomain.com,但我假设您正在尝试在浏览器上键入“localhost”来连接它。这样 apache 将使用默认的 vhost 而不是你的,这可能是在 /etc/apache/sites-enabled/default 上定义的。

    您可以将 mydomain.com 设置为指向 localhost。在 Linux 上编辑 /etc/hosts 文件,添加以下行:

    127.0.0.1   mydomain.com
    

    【讨论】:

      【解决方案2】:

      假设您的虚拟主机配置文件位于 /etc/apache2/sites-available,您必须在 /etc/apache2/sites-enabled 创建指向它的符号链接,如下所示:

      ln -s /etc/apache2/sites-avaliable/mydomain.com /etc/apache2/sites-enabled/mydomain.com.conf
      

      请注意,sites-enabled 处符号链接的扩展名是 .conf。就我而言,这是必需的,因为它在主配置文件/etc/apache2/apache2.conf 中进行了解释:

      # It is split into several files forming the configuration hierarchy outlined
      # below, all located in the /etc/apache2/ directory:
      #
      #   /etc/apache2/
      #   |-- apache2.conf
      #   |   `--  ports.conf
      #   |-- mods-enabled
      #   |   |-- *.load
      #   |   `-- *.conf
      #   |-- conf-enabled
      #   |   `-- *.conf
      #   `-- sites-enabled
      #       `-- *.conf
      

      最后两行说明只加载了sites-enabled 扩展名为.conf 的文件。

      【讨论】:

        猜你喜欢
        • 2016-01-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-10-06
        • 2021-05-06
        • 2016-03-02
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多