【问题标题】:Phusion Passenger set Environment for subdomain using same document root使用相同文档根的子域的 Phusion 乘客集环境
【发布时间】:2013-05-12 09:33:44
【问题描述】:

我有一个子域“staging.website.com”和“website.com”,我想在不同的环境模式下使用相同的应用程序“关闭”和“登台”。

我在 Apache 中设置了以下 vHost:

<VirtualHost 46.17.91.215:80>
  ServerName staging.website.com
  RackEnv staging 
  # !!! Be sure to point DocumentRoot to 'public'!
  DocumentRoot /home/website/public_html/public   
  <Directory /home/website/public_html/public>
     # This relaxes Apache security settings.
     AllowOverride all
     # MultiViews must be turned off.
     Options -MultiViews
  </Directory>
</VirtualHost>

<VirtualHost 46.17.91.215:80>
  ServerName website.com
  ServerAlias www.website.com
  # !!! Be sure to point DocumentRoot to 'public'!
  DocumentRoot /home/website/public_html/public
  RackEnv closed    
  <Directory /home/website/public_html/public>
     # This relaxes Apache security settings.
     AllowOverride all
     # MultiViews must be turned off.
     Options -MultiViews
  </Directory>
</VirtualHost>

*显然我用“website.com”伪装了我的实际域。

无论 vhosts 中的RackEnv 设置不同,它们在访问时都使用相同的环境。我猜这是由于相同的文档根,但它必须是可以实现的。

我也试过RailsEnv

【问题讨论】:

    标签: ruby-on-rails environment-variables passenger vhosts


    【解决方案1】:

    为了将来参考,我在这里找到了答案:https://groups.google.com/forum/?fromgroups#!topic/phusion-passenger/IKULD5QeLDw

    Phusion Passenger identifies your application by its path. It
    recognizes demo.example.com and example.com as the same app, so the
    used RailsEnv will be whichever gets started first.
    
    You can solve this issue by pointing both domains to different paths.
    These paths may even be symlinks; Phusion Passenger doesn't resolve
    them. So you can create a symlink /var/www/apps/myapp-demo, which
    points to /var/www/apps/myapp, and point demo.example.com's
    DocumentRoot to /var/www/apps/myapp-demo/public.
    

    【讨论】:

      【解决方案2】:

      虽然目前没有记录,但您可以使用指令 PassengerAppGroupName since Passenger 3

      配置将是(注意每个 VirtualHost 块的不同名称):

      <VirtualHost 46.17.91.215:80>
        ServerName staging.website.com
        PassengerAppGroupName website-staging
        RackEnv staging 
        # !!! Be sure to point DocumentRoot to 'public'!
        DocumentRoot /home/website/public_html/public   
        <Directory /home/website/public_html/public>
           # This relaxes Apache security settings.
           AllowOverride all
           # MultiViews must be turned off.
           Options -MultiViews
        </Directory>
      </VirtualHost>
      
      <VirtualHost 46.17.91.215:80>
        ServerName website.com
        PassengerAppGroupName website-closed
        ServerAlias www.website.com
        # !!! Be sure to point DocumentRoot to 'public'!
        DocumentRoot /home/website/public_html/public
        RackEnv closed    
        <Directory /home/website/public_html/public>
           # This relaxes Apache security settings.
           AllowOverride all
           # MultiViews must be turned off.
           Options -MultiViews
        </Directory>
      </VirtualHost>
      

      在这里您可以找到work-in-progress documentation(尚未在他们的网站上发布)。

      【讨论】:

        猜你喜欢
        • 2014-08-04
        • 2012-05-19
        • 1970-01-01
        • 1970-01-01
        • 2010-09-09
        • 1970-01-01
        • 2021-01-07
        • 1970-01-01
        • 2012-09-25
        相关资源
        最近更新 更多