【问题标题】:Directory index forbidden by Options directive error only for ruby 1.8.7 applicationOptions 指令错误禁止的目录索引仅适用于 ruby​​ 1.8.7 应用程序
【发布时间】:2015-06-22 22:53:28
【问题描述】:

这让我发疯了。

我有 2 个不同的 rails 应用程序在同一个 redhat 服务器上运行。 web服务器是apache,app服务器是passenger 5.0

App1 - rails 3.0.2 和 ruby​​ 1.9.3

App2-rails 2.0.3 & ruby​​ 1.8.7

App1 工作正常,这是配置:

<VirtualHost *:8081>
    ServerName server-xyz
    RailsEnv test
    DocumentRoot /webapps/test/app1/current/public
    <Directory />
       Options FollowSymLinks
       AllowOverride None
       Order allow,deny
       Allow from all
    </Directory>
</VirtualHost>

现在,当我运行 app2 时,它会将我带到默认的 apache 页面并给我以下错误:

Options 指令禁止的目录索引: /webapps/test/app2/current/public/

这是 app2 的虚拟主机:

<VirtualHost *:8081>
    ServerName server-xyz
    RailsEnv test
    DocumentRoot /webapps/test/app2/current/public
    <Directory />
       Options FollowSymLinks
       AllowOverride None
       Order allow,deny
       Allow from all
    </Directory>
</VirtualHost>

这是常见的passgenger配置:

LoadModule passenger_module /opt/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/passenger-5.0.8/buildout/apache2/mod_passenger.so
PassengerRoot /opt/ruby-1.9.3/lib/ruby/gems/1.9.1/gems/passenger-5.0.8
PassengerDefaultRuby /opt/ree-1.8.7/bin/ruby_with_env

PassengerLogLevel 1
PassengerMaxPoolSize 10

有人知道为什么它适用于 ruby​​.1.9.3 应用程序而不适用于 ruby​​ 1.8.7 吗?

我尝试关注类似的线程,但无法正常工作。

编辑:我给了 'apache' 对该路径的写入权限。似乎没有帮助。

编辑 2:我在 public 下找到了以下 .htaccess 配置:

/webapps/test/app2/releases/20150622171404/public/.htaccess
# General Apache options
AddHandler fastcgi-script .fcgi
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI


RewriteEngine On

# If your Rails application is accessed via an Alias directive,
# then you MUST also set the RewriteBase in this htaccess file.
#
# Example:
#   Alias /myrailsapp /path/to/myrailsapp/public
#   RewriteBase /myrailsapp

RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]

【问题讨论】:

    标签: ruby-on-rails ruby apache passenger phusion


    【解决方案1】:

    如果您在乘客 5 上并运行 ruby​​ 1.8.7 和 rails 2 应用程序,则需要将 config.ru 添加到应用程序的根目录:

    # config.ru
    # Require your environment file to bootstrap Rails
    require ::File.dirname(__FILE__) + '/config/environment'
    
    # Serve static assets from RAILS_ROOT/public directory
    # use Rails::Rack::Static
    # Dispatch the request
    run ActionController::Dispatcher.new
    

    【讨论】:

      【解决方案2】:

      对于第二个应用程序配置,将其更新为:

      <VirtualHost *:8081>
          ServerName server-xyz
          RailsEnv test
          DocumentRoot /webapps/test/app2/current/public
          <Directory />
             Options FollowSymLinks Indexes
             AllowOverride None
             Order allow,deny
             Allow from all
          </Directory>
      </VirtualHost>
      

      并检查文件系统是否在应用程序目录或上层目录中没有为 Indexes 选项自定义配置的 .htaccess 文件

      【讨论】:

      • 谢谢罗拉。我发布了我找到的 .htaccess 文件。我需要更新它吗?我按照您的建议重新启动了 apache,但没有成功。
      • Options +FollowSymLinks +ExecCGI +Indexes替换Options +FollowSymLinks +ExecCGI
      • 我试过了。还尝试完全删除 .htaccess 并重试。我仍然收到相同的错误:Options 指令禁止的目录索引:
      • 为了再次确定,在进行这些更新时,您重新启动/重新加载了 apache,对吗?因为indexs选项是由于apache配置造成的,与ruby无关
      • 是的,我每次都重新启动它们并仔细检查。
      【解决方案3】:

      如果您使用的是 ruby​​ 1.8.7 和 Rails 2.X。我发现最简单的选择是从乘客 5 降级到乘客 4.0.59。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-05-09
        • 2021-10-20
        • 2011-07-15
        • 2014-03-16
        • 2011-10-28
        • 2018-10-16
        相关资源
        最近更新 更多