【发布时间】:2014-10-29 06:51:05
【问题描述】:
我想为 Apache2 配置多个虚拟主机。
似乎类似于:Apache2 weird redirection. (Default site overriding others),但该问题没有答案。
我用过:
apache2cts -S
检查配置状态,结果:
VirtualHost configuration:
*:80 is a NameVirtualHost
default server vbox4.dev.local (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost vbox4.dev.local (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost www.example.com (/etc/apache2/sites-enabled/www.example.com.conf:4)
alias example.com
看来 Apache 知道虚拟主机的存在,但是如果我在浏览器中输入 www.example.com,则在 apache 重新加载后,仍然会显示默认的 apache 页面。
apache2 virtualhost configuration with two subdirectories 靠近但对我没有帮助。 Configuring virtual hosts on apache2 在我看来非常相似,但它没有给我足够的信息来解决我的问题。
我已经遵循了一些建议,但是在实施时我发现这不起作用(不再)我已经阅读了其他建议。为了简短起见,我不会在这里重复这些。
我的系统:
- 在 Virtualbox 客户端中运行
- 使用 Ubuntu 14.04 作为客户端操作系统
我采取的步骤:
- 遵循http://www.debian-administration.org/article/412/Hosting_multiple_websites_with_Apache2 的原始说明
- 结果:在浏览器 localhost 中显示“Apache2 Ubuntu 默认页面” ** 所以 apache2 本身似乎运行正常。
- 我按照“www.example.com”文档中的所有步骤进行操作
- 我在 /var/www/www.example.com/htdocs 中添加了一个非常小的 index.html 文件来标识此站点
并重新加载了apache
- 结果:浏览器指向默认本地主机“Apache2 Ubuntu 默认页面” 但不是我预期的该域的小型 index.html 文件。
/var/log/apache2/error.log 没有显示错误。
我在哪里犯了错误,如何解决?
【问题讨论】:
标签: apache ubuntu virtualhost