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



这让我抓狂。

我有两个不同的rails应用程序在同一台redhat服务器上运行。web服务器是apache,应用程序服务器是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>

这是常见的密码配置:

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]

如果您乘坐的是乘客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>

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

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

最新更新