【问题标题】:How to configure subdomains for Apache2 on Ubuntu?如何在 Ubuntu 上为 Apache2 配置子域?
【发布时间】:2011-10-13 18:48:25
【问题描述】:

我关注了这些instructions to configure subdomains for apache。我可以使用http://localhost/test 访问子域,尽管我无法通过http://test.localhost 访问它。如何实现后者?

# /etc/apache2/sites-available/test.localhost
<VirtualHost *:80>

    # Server name
    ServerName test.localhost

    # Document root
    DocumentRoot /var/www/test/

    # Custom log file locations
    ErrorLog  /var/www/test/logs/error.log
    CustomLog /var/www/test/logs/access.log combined

</VirtualHost>

【问题讨论】:

  • 当您按照描述进行操作时,它应该可以工作。那么你错过了什么?
  • 您是否将 test.localhost 添加到您的主机文件以确保它解析为 127.0.0.1?
  • @Marc B - 谢谢!我按照教程中的描述将子域配置为 127.0.0.2。现在它起作用了!请让我给你答案标志。

标签: apache configuration dns subdomain virtualhost


【解决方案1】:

由于 Mark B 已经正确回答,问题是 /etc/hosts 中的配置错误。正确的配置是:

# /etc/hosts
127.0.0.1     test.localhost

【讨论】:

    【解决方案2】:

    您链接到的博客文章(来自我的博客)指示设置一个新的 VirtualHost 元素,其 ip 为 127.0.0.2,以便您可以轻松创建多个子域。

    您使用 127.0.0.1 进行设置将非常适合一个子域,但如果您打算添加更多,我建议您按照帖子中的说明设置新的 VirtualHost 元素。

    【讨论】:

      【解决方案3】:

      在使用 apache tomcat 7 和 ubuntu 服务器时,配置子域非常容易。

      http://javatute.com/javatute/faces/post/tomcat/2014/configuring-subdomain-in-server.xml.xhtml

      实际上子域需要时间来配置,因为我们使用 cPanel 添加它至少 2-3 天,然后配置 server.xml 并重新启动 tomcat 我们可以按预期运行它。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-05-26
        • 2016-06-21
        • 1970-01-01
        • 2021-01-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-08-11
        相关资源
        最近更新 更多