Apache: VirtualHost *:80 -- 不支持将 * 端口和非 * 端口与 NameVirtualHost 地址混合使用

use*_*761 3 configuration apache-2.2

当我将以下行添加到 时/etc/apache2/apache2.conf,我在重新启动 apache 后收到以下错误:

Include
/usr/share/doc/apache2.2-common/examples/apache2/extra/httpd-vhosts.conf
Run Code Online (Sandbox Code Playgroud)

[Mon Jun 14 12:16:47 2010] [error] VirtualHost *:80 -- 不支持将 * 端口和非 * 端口与 NameVirtualHost 地址混合,结果未定义 [Mon Jun 14 12:16:47 2010] ] [警告] NameVirtualHost *:80 没有 VirtualHosts

这是我的 httpd-vhosts.conf 文件:

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.

<VirtualHost *:80>
   ServerName tirengarfio.com
   DocumentRoot /var/www/rs3

   <Directory /var/www/rs3>
      AllowOverride All
      Options MultiViews Indexes SymLinksIfOwnerMatch
      Allow from All
   </Directory>

   Alias /sf /var/www/rs3/lib/vendor/symfony/data/web/sf
   <Directory "/var/www/rs3/lib/vendor/symfony/data/web/sf">
    AllowOverride All
    Allow from All
   </Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

知道是什么原因造成的吗?

小智 6

您的 http.conf 中还有另一个 NameVirtualHost 条目导致了此问题。寻找像NameVirtualHost *:*某处这样的条目,删除它应该可以消除该错误。

此外,作为旁注,直接从示例文档中包含 httpd-vhosts.conf 可能不是一个好主意,因为根据权限,它可能不是特别安全。它也不是其他人期望的地方,尽管如果您是唯一一个管理服务器的人,那么问题就不那么严重了。