2013-04-08 63 views
1

我需要一些幫助,以獲取在cPanel配置的Apache站點的子uri中工作的Rails 3.2應用程序。我遵循Passenger文檔和各種博客帖子中的步驟。根操作呈現正常,但每隔一個請求給我一個404.使用Apache 2,Rails 3.2和Phusion Passenger配置子uri時遇到問題

我認爲這是在Apache中,而不是Rails,配置,因爲它不是Rails應用程序的404頁面,並且404不會留下痕跡Rails日誌。

下面是httpd.conf中的虛擬主機部分,通過的cPanel產生:

<VirtualHost myip:443> 
    ServerName mysite.org 
    ServerAlias www.mysite.org 
    DocumentRoot /home/myuser/public_html 
    ServerAdmin [email protected] 
    UseCanonicalName Off 
    Options -ExecCGI -Includes 
    RemoveHandler cgi-script .cgi .pl .plx .ppl .perl 
    CustomLog /usr/local/apache/domlogs/mysite.org combined 
    CustomLog /usr/local/apache/domlogs/mysite.org-bytes_log "%{%s}t %I .\n%{%s}t %O ." 
    ## User myuser # Needed for CPanel::ApacheConf 
    UserDir disabled 
    UserDir enabled myuser 
    <IfModule mod_suphp.c> 
     suPHP_UserGroup myuser myuser 
    </IfModule> 
    <IfModule !mod_disable_suexec.c> 
     <IfModule !mod_ruid2.c> 
      SuexecUserGroup myuser myuser 
     </IfModule> 
    </IfModule> 
    <IfModule mod_ruid2.c> 
     RUidGid myuser myuser 
    </IfModule> 
    SSLEngine on 

    SSLCertificateFile /etc/ssl/certs/mysite.org.crt 
    SSLCertificateKeyFile /etc/ssl/private/mysite.org.key 
     SSLCACertificateFile /etc/ssl/certs/mysite.org.cabundle 
    CustomLog /usr/local/apache/domlogs/mysite.org-ssl_log combined 
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown 
    <Directory "/home/myuser/public_html/cgi-bin"> 
     SSLOptions +StdEnvVars 
    </Directory> 
    Include "/usr/local/apache/conf/userdata/ssl/2/myuser/mysite.org/*.conf" 

</VirtualHost> 

這裏是包含文件的最新版本,我把共同爲子URI:

RewriteEngine On 
RewriteOptions Inherit 
RailsEnv production 

<Directory /home/myuser/public_html> 
    Options Indexes FollowSymLinks -MultiViews 
    AllowOverride all 
    Order allow,deny 
    Allow from all 
</Directory> 

RackBaseURI /home/myrailsapp/current 
<Directory /home/myuser/public_html/railsapp> 
    Options -MultiViews 
</Directory> 

/home/myuser/public_html/railsapp是/ home/myrailsapp/current/public的符號鏈接

這裏是/home/myrailsapp/current/public/.htaccess

RackBaseURI /railsapp 
SetEnv GEM_HOME /usr/local/lib/ruby/gems 
PassengerEnabled On 
PassengerAppRoot /home/myrailsapp/current/ 

/home/myrailsapp和/ home/mysite中的所有文件都屬於myuser。 (我沒有看到任何權限錯誤。)

在我的路線文件:

resources :widgets 
    root :to => 'widgets#index' 

當我瀏覽到https://mysite.org/railsapp它正確地顯示小工具的索引,包括資產。當我去https://mysite.org/railsapp/widgetshttps://mysite.org/railsapp/widgets/index時,我得到了Apache 404,並且Rails日誌中沒有條目。

我錯過了什麼?

回答

1

事實證明,/ home/myuser/public_html中的.htaccess正在重寫所有內容。/mysite/railsapp的請求被豁免,因爲它匹配了目錄名稱。我通過添加了

RewriteEngine off 

到/home/myrailsapp/current/public/.htaccess。

1

RewriteEngine off添加到.htaccess確實解決了問題。

相關問題