如何在 Ubuntu 上为 Apache2 配置子域? [英] How to configure subdomains for Apache2 on Ubuntu?

查看:28
本文介绍了如何在 Ubuntu 上为 Apache2 配置子域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照这些说明为 apache 配置子域.我可以使用 http://localhost/test 访问子域,但我无法通过 http://test.localhost 访问它.我怎样才能实现后者?

I followed these instructions to configure subdomains for apache. I can access the subdomain using http://localhost/test though I cannot access it via http://test.localhost. How can I realize the latter?

# /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>

推荐答案

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

As Mark B already answered correctly the problem was a misconfiguration in /etc/hosts. The correct configuration is:

# /etc/hosts
127.0.0.1     test.localhost

这篇关于如何在 Ubuntu 上为 Apache2 配置子域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆