![使用 Plone 4.1 时设置具有多个虚拟主机的 Apache](https://linux22.com/image/566599/%E4%BD%BF%E7%94%A8%20Plone%204.1%20%E6%97%B6%E8%AE%BE%E7%BD%AE%E5%85%B7%E6%9C%89%E5%A4%9A%E4%B8%AA%E8%99%9A%E6%8B%9F%E4%B8%BB%E6%9C%BA%E7%9A%84%20Apache.png)
我有一个在 CentOS 上运行的 Plone 服务器,我有多个运行 4.0 和 4.1 的 Plone 实例,我还有多个站点。我是 Linux 新手,在让 Apache 与多个虚拟主机一起工作时遇到了问题。列出的第一个主机工作正常,但第二个主机却不行。启动 HTTPD 时收到以下错误消息:
Starting httpd: [Mon Nov 07 14:38:31 2011] [warn] VirtualHost ordevel3.ucdavis.edu:80 overlaps with VirtualHost ordevel4.ucdavis.edu:80,
the first has precedence, perhaps you need a NameVirtualHost directive.
我缺少什么才能使虚拟主机正常工作?
下面是我在 httpd.conf 中的语法。
<VirtualHost ordevel3.abc.edu:80>
ServerAlias ordevel3.abc.edu
ServerAdmin [email protected]
ServerSignature On
<IfModule mod_rewrite.c>
RewriteEngine On
# serving icons from apache 2 server
RewriteRule ^/icons/ - [L]
RewriteRule ^/(.*) \
http://localhost:8080/VirtualHostBase/http/%{SERVER_NAME}:80/itsdevel3/VirtualHostRoot/$1 [L,P]
</IfModule>
<IfModule mod_proxy.c>
ProxyVia On
# prevent the webserver from beeing used as proxy
<LocationMatch "^[^/]">
Deny from all
</LocationMatch>
</IfModule>
</VirtualHost>
<VirtualHost ordevel4.abc.edu:80>
ServerAlias ordevel4.abc.edu
ServerAdmin [email protected]
ServerSignature On
<IfModule mod_rewrite.c>
RewriteEngine On
# serving icons from apache 2 server
RewriteRule ^/icons/ - [L]
RewriteRule ^/(.*) \
http://localhost:8180/VirtualHostBase/http/%{SERVER_NAME}:80/ITS/VirtualHostRoot/$1 [L,P]
</IfModule>
<IfModule mod_proxy.c>
ProxyVia On
# prevent the webserver from beeing used as proxy
<LocationMatch "^[^/]">
Deny from all
</LocationMatch>
</IfModule>
</VirtualHost>
答案1
您需要更改以下几行:
<VirtualHost ordevel3.abc.edu:80>
ServerAlias ServerAlias ordevel3.abc.edu
第一行应该包含 IP 或 *(通配符),而不是域名。如果您想使用基于名称的 VirtualHosts,则应定义 ServerName。ServerAlias 仅用于向已有名称的 VirtualHost 添加别名。
因此这些行应该如下所示:
<VirtualHost *:80>
ServerName ordevel3.abc.edu
如果此虚拟主机可以通过名称 sth.ordevel3.abc.edu 访问,则可以添加别名:
ServerAlias sth.ordevel3.abc.edu
如果仍然出现相同的错误,则必须确保您的 httpd.conf 包含以下行以激活命名虚拟主机:
NameVirtualHost *:80
欲了解更多信息,可以查阅 Apache 手册:
附言:我没有仔细查看您的重定向和其他配置,因为这不是问题所在。