这是启动Apache2时出现的错误:
* Starting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName [Wed Oct 21 16:37:26 2009] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results [Wed Oct 21 16:37:26 2009] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results [Wed Oct 21 16:37:26 2009] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results [Wed Oct 21 16:37:26 2009] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results [Wed Oct 21 16:37:26 2009] [warn] NameVirtualHost *:80 has no VirtualHosts
我首先遵循这个指南设置Apache来承载多个站点:
http://www.debian-administration.org/articles/412
然后,我在ServerFault上发现了一个类似的问题 ,并尝试应用该解决scheme,但没有帮助。
这里是我最后的VirtualHostconfiguration的一个例子:
<VirtualHost *:80> ServerAdmin [email protected] ServerName www.xxx.com ServerAlias xxx.com # Indexes + Directory Root. DirectoryIndex index.html DocumentRoot /var/www/www.xxx.com # Logfiles ErrorLog /var/www/www.xxx.com/logs/error.log CustomLog /var/www/www.xxx.com/logs/access.log combined </VirtualHost>
与域名X'd出来保护无辜的:-)
另外,我有指南中提到的conf.d / virtual.conf文件,如下所示:
NameVirtualHost *
奇怪的是,这三个网站中的两个都能正常工作。
使用NameVirtualHost
命名的IP地址必须与每个VirtualHost
元素中的IP地址相匹配。
例:
NameVirtualHost *:80 NameVirtualHost *:81 <VirtualHost *:80> # ... </VirtualHost> <VirtualHost *:81> # ... </VirtualHost> # This will not work! <VirtualHost *> # ... </VirtualHost>
有关详细信息,请阅读Apache Virtual Host文档 。
replace这个:
NameVirtualHost *
有了这个:
NameVirtualHost *:80
添加到响应中,我注意到的一件事是,如果没有在每个NameVirtualHost和VirtualHost指令中显式声明:80,则不能运行SSL,apache将不支持:
NameVirtualHost *
和
NameVirtualHost *:443
在同一个configuration中混淆起来,如果你这样做的话,你将在apache监听端口0时发生错误。
对于我来说,我只是把80添加到每个主机上,这样SSL就可以正常工作。
例如:
<VirtualHost 85.25.97.252:80>
ServerName domain.com
ServerAlias * .domain.com
ServerAdmin [email protected]
DocumentRoot“/var/www/domain.com/httpdocs/”
<目录“/var/www/domain.com/httpdocs /”>
选项索引FollowSymLinks
AllowOverride全部
订单允许,否认
全部允许
</目录>
</虚拟主机>