【问题标题】:Apache2 multiple name-based virtual hosts on one machine with rails/rack一台机器上的 Apache2 多个基于名称的虚拟主机,带有 rails/rack
【发布时间】:2013-05-08 23:48:18
【问题描述】:

我坚持将 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

【问题讨论】:

    标签: ruby-on-rails apache apache2 passenger vhosts


    【解决方案1】:

    在#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-12-13
      • 1970-01-01
      • 1970-01-01
      • 2015-07-10
      • 1970-01-01
      • 1970-01-01
      • 2012-01-22
      • 2015-12-07
      • 2014-08-07
      相关资源
      最近更新 更多