[英]Directory index forbidden by Options directive error only for ruby 1.8.7 application
This is driving me nuts. 这让我发疯。
I have 2 different rails app running on the same redhat server. 我在同一redhat服务器上运行2个不同的Rails应用程序。 The web server is apache and app server is passenger 5.0
Web服务器是apache,而应用程序服务器是passenger 5.0
App1 - rails 3.0.2 and ruby 1.9.3
App1-滑轨3.0.2和红宝石1.9.3
App2- rails 2.0.3 & ruby 1.8.7
App2-滑轨2.0.3和红宝石1.8.7
App1 works fine and this is the configuration: 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>
Now when I run app2 it takes me to the default apache page and gives me the following error: 现在,当我运行app2时,它将带我到默认的Apache页面,并显示以下错误:
Directory index forbidden by Options directive: /webapps/test/app2/current/public/
选项指令禁止的目录索引:/ webapps / test / app2 / current / public /
This is the virtual host for app2: 这是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>
This is the common passgenger configuration: 这是常见的密码生成器配置:
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
Anyone has any ideas why it works for ruby.1.9.3 app and not for ruby 1.8.7? 任何人有任何想法为什么它适用于ruby.1.9.3应用程序而不适用于ruby 1.8.7?
I tried following similar threads but couldnt get it to work. 我尝试遵循类似的线程,但无法使其正常工作。
EDIT: I gave 'apache' write permissions to that path. 编辑:我给了“ apache”对该路径的写权限。 Didn't seem to help.
似乎没有帮助。
EDIT 2: I found the following .htaccess configuration under public: 编辑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]
If you are on passenger 5 and running ruby 1.8.7 & rails 2 app, you need to add a config.ru to the root of your application: 如果您在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
For the second application configuration, update it with: 对于第二个应用程序配置,请使用以下命令进行更新:
<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>
and check the filesystem that you don't have a .htaccess file with custom configuration for the Indexes option either on the app directory or on a upper directory 并检查您没有在应用程序目录或上层目录上具有针对Indexes选项进行自定义配置的.htaccess文件的文件系统
If you are using ruby 1.8.7 and Rails 2.X. 如果您使用的是ruby 1.8.7和Rails2.X。 I found the easiest option was to downgrade from passenger 5 to passenger 4.0.59.
我发现最简单的选择是将乘客5降级为乘客4.0.59。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.