【问题标题】:Why does rails app show /public index listing instead of actual app?为什么 Rails 应用程序显示 /public 索引列表而不是实际应用程序?
【发布时间】:2012-05-21 22:16:43
【问题描述】:

如何设置 apache 以在 rails 应用程序在服务器上时显示它?我的 rails 应用程序在本地主机上运行良好,但是当我转到外部站点时,它会为我提供索引信息

喜欢这个

Name    Last modified   Size    Description
[TXT]   404.html    21-May-2012 21:38   728      
[TXT]   422.html    21-May-2012 21:38   711      
[TXT]   500.html    21-May-2012 21:38   643      
[IMG]   favicon.ico 21-May-2012 21:38   0    
[TXT]   robots.txt  21-May-2012 21:38   204      

这是我的虚拟主机信息

<VirtualHost *:80>
      ServerAdmin example@example.com
      ServerName server.example.com
      # ServerAlias
      DocumentRoot /var/www/sample_app/current/public
      ErrorLog /var/www/sample_app/error.log

          RailsEnv production
        <Directory "/var/www/sample_app/current/public">
          Options Indexes FollowSymLinks MultiViews
          Order allow,deny
          Allow from all
        </Directory>
</VirtualHost>

【问题讨论】:

  • 对不起,如果这是一个愚蠢的问题,但是您是否设置了诸如 Mongrel Cluster 或Passenger 之类的东西...?
  • 是的,乘客正在工作

标签: ruby-on-rails apache virtualhost


【解决方案1】:

好吧,可能不是这样,但这是 Passenger's documentation 的建议:

<VirtualHost *:80>
    ServerName www.mycook.com
    DocumentRoot /webapps/mycook/public
    <Directory /webapps/mycook/public>
        Allow from all
        Options -MultiViews
    </Directory>
</VirtualHost>

明确指出 MultiViews 与Passenger兼容。

所以你可以试试:

  • 删除索引选项
  • 指定-MultiViews 而不是MultiViews

说实话,我已经尝试将索引添加到我的生产应用程序中,因为我认为这可能只是导致问题的这个选项,但它并没有改变任何东西......所以它有点“疯狂的猜测”,它可能会解决您的问题。

更新another answer,您可以尝试添加PassengerResolveSymlinksInDocumentRoot 选项:

<VirtualHost *:80>
    ServerName www.mycook.com
    DocumentRoot /webapps/mycook/public
    <Directory /webapps/mycook/public>
        Allow from all
        Options -MultiViews
        PassengerResolveSymlinksInDocumentRoot on
    </Directory>
</VirtualHost>

【讨论】:

  • 很遗憾,这不起作用,但谢谢。您对 MultiViews 的看法是正确的
  • 好的,抱歉没用!如果您使用符号链接,我发现这个已回答的问题可能会有所帮助:stackoverflow.com/questions/2923588/…
  • Re: 否决票已接受 我能够使用以下方法解决此问题:PassengerResolveSymlinksInDocumentRoot 似乎Passenger 不再处理默认情况下指向您的应用程序的符号链接的公共目录。启用此选项可解决所有问题。你知道如何开启这个选项吗?
  • 看来我需要的信息在这里。 my.hostmonster.com/cgi/help/rails 谢谢
  • 好吧,我已经更新了我的答案来解决你的问题^^
猜你喜欢
  • 2015-07-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-04-07
  • 2016-01-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多