繁体   English   中英

选项指令禁止的目录索引错误仅适用于ruby 1.8.7应用程序

[英]Directory index forbidden by Options directive error only for ruby 1.8.7 application

这让我发疯。

我在同一redhat服务器上运行2个不同的Rails应用程序。 Web服务器是apache,而应用程序服务器是passenger 5.0

App1-滑轨3.0.2和红宝石1.9.3

App2-滑轨2.0.3和红宝石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页面,并显示以下错误:

选项指令禁止的目录索引:/ 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>

这是常见的密码生成器配置:

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:我在公共下找到以下.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]

如果您在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

对于第二个应用程序配置,请使用以下命令进行更新:

<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文件的文件系统

如果您使用的是ruby 1.8.7和Rails2.X。 我发现最简单的选择是将乘客5降级为乘客4.0.59。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM