这是我在启动 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 *
奇怪的是,这三个站点中的两个站点似乎一切正常。
以 命名的 IP 地址
NameVirtualHost
必须与每个VirtualHost
元素中的 IP 地址相匹配。例子:
有关详细信息,请阅读Apache 虚拟主机文档。
替换这个:
有了这个:
添加到响应中,我注意到的一件事是,如果没有在每个 NameVirtualHost 和 VirtualHost 指令上明确声明 :80 就无法运行 SSL,apache 将不支持:
名称虚拟主机 *
和
名称虚拟主机 *:443
混合在同一个配置中,如果你这样做,你会在 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/"
<Directory "/var/www/domain.com/ httpdocs/">
选项索引 FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>