[英]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.