虚拟主机问题

虚拟主机问题

我在 Linode 上托管了一个 Ubuntu 服务器,上面有很多网站/var/www目录。

我有 2 个注册域名(preplogs.com、icerge.com 以及我通过 8.8.8.8/domain 访问的许多其他网站)每个都指向/var/www目录。

我的问题是我的虚拟主机定义没有按照我预期的那样响应。

我已经默认了000-默认.conf主机如下:

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www

        LimitRequestFieldSize 100000

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

第二个虚拟主机称为配置文件

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/icerge

        LimitRequestFieldSize 100000

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

第三个域称为preplogs.com

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        ServerName www.preplogs.com
        ServerAlias preplogs.com
        ServerAlias www.preplog.com
        ServerAlias preplog.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/DrupalQuiz

        LimitRequestFieldSize 100000

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

我的问题是,当我访问不同的地址时,我无法找到正确的网站。

当我访问该 IP 地址时,我希望看到服务器上所有域名的“索引”列表,但我看到的却是预备日志地点。

Preplogs.com 按预期加载 preplogs 网站。

icerge.com 加载服务器的列表“索引”。

有人能帮忙吗?我不知道该如何解决这个烂摊子。

答案1

您尚未在前两个 vhost 配置上设置ServerName和。ServerAlias

  1. 设置默认虚拟主机,它将处理使用 IP 地址的情况或类似情况。将 ServerName 留空。
  2. 为每个站点设置一个虚拟主机。这些应该包含ServerName和可能ServerAlias

您可能还想设置该ServerAdmin字段,因为它在错误页面上用作联系点。

相关内容