[英]Apache2 multiple name-based virtual hosts on one machine with rails/rack
Am stuck on configuring apache to serve up two different sites with Name based virtual hosts at: 我坚持配置apache以使用基于名称的虚拟主机提供两个不同的站点:
http://experimental/
and 和
http://api.experimental/
On one machine this setup works fine, and apache reports this: 在一台机器上这个设置工作正常,apache报告:
apachectl -D DUMP_VHOSTS
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:* is a NameVirtualHost
default server experimental (/etc/apache2/sites-enabled/00-nowa.conf:3)
port * namevhost experimental (/etc/apache2/sites-enabled/00-nowa.conf:3)
port * namevhost api.experimental (/etc/apache2/sites-enabled/00-nowa.conf:15)
Syntax OK
On the 2nd machine this does not work, both URLS end up pointing to the first app, it's output of the same command is which has additional : lines: 在第二台机器上这不起作用,两个URL最终指向第一个应用程序,它的相同命令的输出是有另外的:行:
apachectl -D DUMP_VHOSTS
apache2: apr_sockaddr_info_get() failed for experimental
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[Tue May 14 15:36:08 2013] [warn] NameVirtualHost *:80 has no VirtualHosts
[Tue May 14 15:36:08 2013] [warn] NameVirtualHost *:80 has no VirtualHosts
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:* experimental (/etc/apache2/sites-enabled/00-nowa.conf:3)
*:* api.experimental (/etc/apache2/sites-enabled/00-nowa.conf:15)
Syntax OK
The vhost files for each machine are this for the broken one: 每台机器的vhost文件都是针对破坏的文件:
<VirtualHost *>
ServerName experimental
RailsEnv production
DocumentRoot /home/nowa/nowa_app/nowa/current/public
<Directory /home/nowa/nowa_app/nowa/current/public >
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>
<VirtualHost *>
ServerName api.experimental
RackEnv production
PassengerMinInstances 2
PassengerMaxPoolSize 10
DocumentRoot /home/nowa/nowa_app/services/api_gateway/current/app
</VirtualHost>
And working : 工作 :
<VirtualHost *>
ServerName experimental
RailsEnv production
DocumentRoot /home/nowa/nowa_app/nowa/current/public
<Directory /home/nowa/nowa_app/nowa/current/public >
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>
<VirtualHost *>
ServerName api.experimental
RackEnv production
PassengerMinInstances 2
PassengerMaxPoolSize 10
DocumentRoot /home/nowa/nowa_app/services/nowa_api_gateway/current/app
</VirtualHost>
Why is the output of apachectl -D DUMP_VHOSTS different? 为什么apachectl -D DUMP_VHOSTS的输出不同? What have I missed? 我错过了什么? :C :C
Asked on the #httpd irc room and turns out apache was misinterpreting 在#httpd irc房间问道,结果是apache被误解了
<VirtualHost *>
as an IP based vhost entry, not a name based one, changing it to this fixed it: 作为基于IP的vhost条目,而不是基于名称的vhost条目,将其更改为固定它:
<VirtualHost *:80>
This was because NameVirtualHost was defined like this on the broken server: 这是因为NameVirtualHost在损坏的服务器上定义如下:
NameVirtualHost *:80
Complete working config: 完整的工作配置:
<VirtualHost *:80>
ServerName experimental
RailsEnv production
DocumentRoot /home/nowa/nowa_app/nowa/current/public
<Directory /home/nowa/nowa_app/nowa/current/public >
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName api.experimental
RackEnv production
PassengerMinInstances 2
PassengerMaxPoolSize 10
DocumentRoot /home/nowa/nowa_app/services/api_gateway/current/app
</VirtualHost>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.