1

我有一个子域“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”伪装了我的实际域。

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

我也试过了RailsEnv

4

2 回答 2

2

为了将来参考,我在这里找到了答案: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.
于 2013-05-17T09:14:22.547 回答
2

虽然现在没有记录,但您可以使用PassengerAppGroupName 从 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>

在这里您可以找到正在进行的文档(尚未在他们的网站上发布)。

于 2014-10-14T13:55:16.713 回答