Phusion Passenger使用相同的文档根设置子域的环境

时间:2022-10-04 00:07:01

I have a subdomain "staging.website.com" and "website.com" which I want to use the same app for but in different environment modes "closed" and "staging".

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

I have the following vHosts set up in Apache:

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

*Obviously I have disguised my actual domain with "website.com".

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

Regardless of the different RackEnv set in the vhosts, they both use the same environment when accessed. I guess this is due to the same document root, but it must be achievable.

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

I have also tried with RailsEnv.

我也试过RailsEnv。

2 个解决方案

#1


2  

For future reference, I found the answer here: https://groups.google.com/forum/?fromgroups#!topic/phusion-passenger/IKULD5QeLDw

为了将来参考,我在这里找到了答案: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


1  

Although undocumented right now, you can use the directive PassengerAppGroupName since Passenger 3.

虽然现在没有记录,但您可以使用自乘客3以来的指令PassengerAppGroupName。

The config would be (note the different names for every VirtualHost block):

配置将是(注意每个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>

Here you can find the work-in-progress documentation (not published in their website yet).

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

#1


2  

For future reference, I found the answer here: https://groups.google.com/forum/?fromgroups#!topic/phusion-passenger/IKULD5QeLDw

为了将来参考,我在这里找到了答案: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


1  

Although undocumented right now, you can use the directive PassengerAppGroupName since Passenger 3.

虽然现在没有记录,但您可以使用自乘客3以来的指令PassengerAppGroupName。

The config would be (note the different names for every VirtualHost block):

配置将是(注意每个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>

Here you can find the work-in-progress documentation (not published in their website yet).

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