【问题标题】:Apache two domains on two different ip addresses两个不同IP地址上的Apache两个域
【发布时间】:2014-12-17 20:04:00
【问题描述】:

我正在尝试在两个不同的 IP 地址上设置两个不同的域:bbb.zzz.xxx.yyy & bbb.xxx.yyy.zzz 。问题是,domain1 工作正常。当我在浏览器中输入 ip 地址时,第二个站点 (domain2) 正在工作,但当我输入 wwww.domain2.com 时它显示 domain1 的内容。我应该如何解决这个问题?是否缺少任何模块?我在站点可用目录中为不同的域使用不同的文件。

<VirtualHost bbb.zzz.xxx.yyy>
  # Admin email, Server Name (domain name) and any aliases
  ServerAdmin **********@gmail.com
  ServerName domain1.com
  ServerAlias www.domain1.com

  # Index file and Document Root (where the public files are located)
  DirectoryIndex  index.php
  DocumentRoot /home/ApacheWebsites/domain1/httpdocs

  # Custom log file locations
  LogLevel warn
  ErrorLog /home/ApacheWebsites/logs/error.log


 CustomLog /home/ApacheWebsites/logs/access.log combined


    <Directory /home/ApacheWebsites/domain1/httpdocs/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
           Require all granted
            allow from all
    </Directory>

<VirtualHost bbb.xxx.yyy.zzz>
  # Admin email, Server Name (domain name) and any aliases
      ServerAdmin ************@gmail.com
      ServerName domain2.com
      ServerAlias www.domain2.com

      # Index file and Document Root (where the public files are located)
      DirectoryIndex  index.php
      DocumentRoot /home/ApacheWebsites/domain2

      # Custom log file locations
      LogLevel warn
      ErrorLog /home/ApacheWebsites/logs/error.log
     CustomLog /home/ApacheWebsites/logs/access.log combined
        <Directory /home/ApacheWebsites/domain2/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
               Require all granted
                allow from all
        </Directory>
</VirtualHost>

【问题讨论】:

    标签: apache ubuntu virtualhost


    【解决方案1】:

    你的第一个 sn-p 说

    ServerName domain1.com
    ServerAlias www.domain2.com
    

    将服务器别名更改为 www.domain1.com,它应该可以工作。

    【讨论】:

    • 哦,抱歉,它解析为分配给 domain1 的 IP 地址
    • 更改它并再次测试;)
    • 它不工作。 www.domain2.com 仍然加载 domain1 的内容(不是当我直接使用 ip 地址时)。我需要启用任何模块吗?
    • 您可以尝试通过 定义两个虚拟主机。这会忽略传入的 IP 地址,并将您的域与两个主机匹配。
    猜你喜欢
    • 1970-01-01
    • 2013-07-02
    • 2017-09-28
    • 2012-11-30
    • 2014-08-05
    • 2012-06-26
    • 1970-01-01
    • 1970-01-01
    • 2016-11-19
    相关资源
    最近更新 更多