仅适用于 ruby 1.8.7 应用程序的 Options 指令错误禁止目录索引
Directory index forbidden by Options directive error only for ruby 1.8.7 application
这让我抓狂。
我在同一个 redhat 服务器上有 2 个不同的 rails 应用程序 运行ning。 Web服务器是apache,应用服务器是passenger 5.0
App1 - rails 3.0.2 and 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 页面并给我以下错误:
Directory index forbidden by Options directive:
/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 ^([^.]+)$ .html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
对于第二个应用程序配置,将其更新为:
<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 选项自定义配置
如果您使用的是 passenger 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
如果您使用的是 ruby 1.8.7 和 Rails 2.X。我发现最简单的选择是将 passenger 5 降级到 passenger 4.0.59。
这让我抓狂。
我在同一个 redhat 服务器上有 2 个不同的 rails 应用程序 运行ning。 Web服务器是apache,应用服务器是passenger 5.0
App1 - rails 3.0.2 and 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 页面并给我以下错误:
Directory index forbidden by Options directive: /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 ^([^.]+)$ .html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
对于第二个应用程序配置,将其更新为:
<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 选项自定义配置
如果您使用的是 passenger 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
如果您使用的是 ruby 1.8.7 和 Rails 2.X。我发现最简单的选择是将 passenger 5 降级到 passenger 4.0.59。