当我的 Ubuntu Apache 服务器 (Apache 2) 启动时,我收到一条警告消息,内容如下:
[warn] NameVirtualHost *:80 has no VirtualHosts
但是,Web 服务器运行良好。我网站的配置可能有什么问题,使它给我这个警告?
有问题的配置文件(位于/etc/apache2/sites-available)读起来像(为简洁起见,删除了详细信息)
<VirtualHost *>
<Location /mysite>
# Configuration details here...
</Location>
# Use the following for authorization.
<LocationMatch "/mysite/login">
AuthType Basic
AuthName "My Site"
AuthUserFile /etc/sitepasswords/passwd
Require valid-user
</LocationMatch>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
我正在使用的事实可能是<Location>问题的一部分吗?
Dav*_*ney 53
改变
<VirtualHost *>
Run Code Online (Sandbox Code Playgroud)
阅读
<VirtualHost *:80>
Run Code Online (Sandbox Code Playgroud)
或者它的 (NameVirtualHost *:80) 在你的 apache2 Confing 文件中添加了两次。(默认情况下,它已添加到ports.conf 文件中)
这应该清除错误。
旁白:你不应该忽略这个错误。Apache 的配置,特别是当 globbing 虚拟主机(例如 Include /etc/httpd/vhosts.d/*)不稳定时。这意味着您无法明确控制加载主机的顺序,因此 IP 的默认虚拟主机成为最先加载的虚拟主机,这可能会导致意想不到的后果。
一个例子是 IP 的默认 vhost 也将在该 IP 上可用,而不是它的name。这可能会导致信息泄露到谷歌,指的是您的网站 IP 而不是名称,这可能会让客户感到困惑。
上面的 NameVirtualHost 错误可能暗示 apache 以非最佳方式加载了东西,所以你不应该忽略它。
Iva*_*van 51
那可能是因为您在不止一个地方拥有 NameVirtualHost 指令。
我不知道其他发行版,但在 Ubuntu/Debian 中,Apache 的配置分为几个文件,因此您必须检查重复的位置(httpd.conf、apache2.conf、ports.conf、conf.d /*)。
哦,我刚刚找到了这个包含更多信息的好资源:Common Apache Misconfigurations。
小智 9
在 Debian/Lenny 机器上:在 /etc/apache2/ports.conf 中有一个额外的 NameVirtualHost 语句 - 这可能是导致此问题的原因(/etc/apache2/sites-available/default 中也有相同的语句) . 我评论了该声明,错误消失了。
| 归档时间: |
|
| 查看次数: |
113453 次 |
| 最近记录: |