2013-05-17 27 views
0

我有一個子域「staging.website.com」和「website.com」,我想在不同的環境模式下使用相同的應用程序「closed」和「staging 」。Phusion Passenger set使用同一個文檔根的子域環境

我在Apache中設置下列虛擬主機:

<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

回答

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. 
+0

請標記爲已解決。 – Fa11enAngel

1

雖然無證,現在,你可以使用指令PassengerAppGroupNamesince Passenger 3

的配置將是(注意每個虛擬主機塊不同的名稱):

<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(未發表他們的網站還)。

相關問題