【问题标题】:Apache "It works" page being shown instead of site defined in virtual host显示 Apache “It works”页面而不是虚拟主机中定义的站点
【发布时间】:2014-11-28 01:14:53
【问题描述】:

我最近在我的 vps 上运行了一个更新,它在 Ubuntu 13.10 上将我的 apache 从 2.2 更新到了 2.4.6。

更新后,我只得到“它可以工作”的默认 apache 登陆页面。

我很确定这是由于新的虚拟主机文件要求,所以我尝试将 .conf 扩展名添加到我的虚拟主机文件并添加:

<Directory "/home/username/public/testapp.com/public/">
    Options Indexes FollowSymLinks Includes
    AllowOverride All
    Require all granted
</Directory>

到文件并使用 a2ensite 重新启用它们并重新加载 apache2。在这些尝试没有取得任何进展后,我删除了所有启用的站点并重新开始......将一个基本站点放入/home/username/public/url.co/并创建一个新的虚拟主机文件:

<VirtualHost *:80>
  # Admin email, Server Name (domain name), and any aliases
  ServerAdmin admin@url.co
  ServerName  url.co
  ServerAlias www.url.co

  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html index.php
  DocumentRoot /home/username/public/url.co/public/

  # Log file locations
  LogLevel warn
  ErrorLog  /home/username/public/url.co/log/error.log
  CustomLog /home/username/public/url.co/log/access.log combined

    <Directory /home/username/public/url.co/public/>
        Options Indexes FollowSymLinks Includes
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

这仍然给了我“它有效”的页面。我是否遗漏了此文件明显错误的内容(正确命名为 url.co.conf ),还是有其他可能导致此问题的内容?

【问题讨论】:

    标签: apache virtualhost ubuntu-13.10


    【解决方案1】:

    我也有同样的问题!我通过在我的 conf 文件中添加:DirectoryIndex index.html index.php 解决了这个问题

    【讨论】:

      【解决方案2】:

      按照以下步骤进行

      1. 做:sudo nano /etc/apache2/extra/httpd-vhosts.conf
      <VirtualHost *:80>
      
        ServerName  website.localhost
        ServerAlias www.website.localhost
      
        # Index file and Document Root (where the public files are located)
        DirectoryIndex index.html index.php
        DocumentRoot "/Users/Username/Sites/website"
      
        # Log file locations
        LogLevel warn
      
        ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
        CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
      
          <Directory /Users/Username/Sites/website>
              Options Includes FollowSymLinks
              AllowOverride All
              Order allow,deny
              Allow from all
               Require all granted
          </Directory>
      </VirtualHost>
      
      1. 允许来自 Apache 配置文件 httpd.confvhosts 配置:

        sudo nano /etc/apache2/httpd.conf

        搜索“vhosts”并取消注释包含行:

        Include /private/etc/apache2/extra/httpd-vhosts.conf

      这将允许使用 HTTP,在 d-vhosts.conf 文件中输入代码,打开此文件以添加 vhost

      1. 执行:sudo nano /etc/hosts 并添加以下内容;

        127.0.0.1 website.localhost

      2. 做:sudo apachectl restart

      您可以替换ErrorLog和CustomeLog或者检查/private/var/log/apache2/中的错误enter code here

      【讨论】:

        猜你喜欢
        • 2019-02-13
        • 1970-01-01
        • 2016-03-06
        • 2020-11-18
        • 1970-01-01
        • 1970-01-01
        • 2014-01-06
        • 2017-06-04
        • 1970-01-01
        相关资源
        最近更新 更多