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

1.6k views Asked by At

This is driving me nuts.

I have 2 different rails app running on the same redhat server. The web server is apache and app server is passenger 5.0

App1 - rails 3.0.2 and ruby 1.9.3

App2- rails 2.0.3 & ruby 1.8.7

App1 works fine and this is the configuration:

<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:

Directory index forbidden by Options directive: /webapps/test/app2/current/public/

This is the virtual host for 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?

I tried following similar threads but couldnt get it to work.

EDIT: I gave 'apache' write permissions to that path. Didn't seem to help.

EDIT 2: I found the following .htaccess configuration under public:

/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]
3

There are 3 answers

0
Micheal On BEST ANSWER

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:

# 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
5
rorra On

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

0
Morgana On

If you are using ruby 1.8.7 and Rails 2.X. I found the easiest option was to downgrade from passenger 5 to passenger 4.0.59.