这是我启动 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 来托管多个站点:
然后我发现类似的问题在 ServerFault 上并尝试应用解决方案,但没有帮助。
以下是我的最终 VirtualHost 配置的示例:
<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 来保护无辜者 :-)
另外,我有conf.d/virtual.conf指南中提到的文件如下所示:
NameVirtualHost *
奇怪的是,这三个站点中有两个站点看上去运行正常。
答案1
以 命名的 IP 地址必须与每个元素NameVirtualHost
中的 IP 地址相匹配。VirtualHost
例子:
NameVirtualHost *:80
NameVirtualHost *:81
<VirtualHost *:80>
# ...
</VirtualHost>
<VirtualHost *:81>
# ...
</VirtualHost>
# This will not work!
<VirtualHost *>
# ...
</VirtualHost>
阅读Apache 虚拟主机文档了解详情。
答案2
替换为:
NameVirtualHost *
有了这个:
NameVirtualHost *:80
答案3
除了响应之外,我注意到的一件事是,如果没有在每个 NameVirtualHost 和 VirtualHost 指令上明确声明 :80,则无法运行 SSL,Apache 不支持:
名称虚拟主机 *
和
名称虚拟主机 *:443
如果混合使用相同的配置,那么在 apache 监听端口零时就会出现错误。
对我来说,我只需向每个主机添加:80,这样 SSL 就可以正常工作。
答案4
前任:
<VirtualHost 85.25.97.252:80>
服务器名称 domain.com
服务器别名 *.domain.com
服务器管理员[电子邮件保护]
DocumentRoot“/var/www/domain.com/httpdocs/”
<Directory“/var/www/domain.com/httpdocs/”>
选项索引FollowSymLinksAllowOverride
所有
顺序允许,拒绝
允许所有
</Directory>
</VirtualHost>