0

我坚持配置 apache 来为两个不同的站点提供基于名称的虚拟主机:

http://experimental/

http://api.experimental/

在一台机器上,这个设置工作正常,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

在第二台机器上这不起作用,两个 URLS 最终都指向第一个应用程序,它的输出相同的命令有额外的行:

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

每台机器的虚拟主机文件是损坏的:

<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>

工作

<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>

为什么 apachectl -D DUMP_VHOSTS 的输出不同?我错过了什么?:C

4

1 回答 1

2

在#httpd irc 房间询问,结果发现 apache 误解了

<VirtualHost *> 

作为基于 IP 的虚拟主机条目,而不是基于名称的条目,将其更改为此已修复:

<VirtualHost *:80>

这是因为 NameVirtualHost 在损坏的服务器上是这样定义的:

NameVirtualHost *:80

完整的工作配置:

<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>
于 2013-05-15T08:37:17.887 回答