Dreaded "Application error" Apache2

Hello,

I’ve been struggling for well over 6 hours which qualifies me as
being allowed to post a question to the list.

I am trying to get my Rails application to run under Apache. It works
fine with WEBrick. Apache is failing in both the cgi and fastcgi modes.

Configuration: Rails 0.14.3, Apache 2.0.50, Ruby 1.8.3, Postgres 8.1,
fcgi-2.4.0, ruby-fcgi-0.8.6.1, SaltedHashLoginGenerator

The permissions all seem to be fine (0755 on the dispatch.* files,
although many variations succeeded and failed as expected) and the
path to Ruby is correct (#!/usr/local/bin/ruby)

No matter what I do, I get the dreaded “Application error Rails
application failed to start properly” error. Some of the interesting
things I’ve found include:

When I run public/dispatch.rb, public/dispatch.cgi, and public/
dispatch.fcgi I get a “Status: 500 Internal Server Error”. Is this
normal?

How about this excerpt from the console, entering the contents of
dispatch.cgi line-by-line, and then trying variations until things work:

Loading development environment.

require File.dirname(FILE) + “/…/config/environment” unless
defined?(RAILS_ROOT)
=> nil

require File.dirname(FILE) + “/…/config/environment”
/usr/local/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/initializer.rb:
222: warning: already initialized constant Controllers
=> true

require “dispatcher”
=> true

ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if
File.directory?(dir) } if defined?(Apache::RubyRun)
=> nil

ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if
File.directory?(dir) }
NameError: uninitialized constant ADDITIONAL_LOAD_PATHS
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.3/
lib/active_support/dependencies.rb:200:in `const_missing’
from (irb):4

Dispatcher.dispatch
Status: 500 Internal Server Error
=> 35

Does this make sense? I get the same kind of error from the .fcgi:

Loading development environment.

require File.dirname(FILE) + “/…/config/environment” unless
defined?(RAILS_ROOT)
=> nil

require File.dirname(FILE) + “/…/config/environment”
/usr/local/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/initializer.rb:
222: warning: already initialized constant Controllers
=> true

require ‘fcgi_handler’
=> true

RailsFCGIHandler.process!
Status: 500 Internal Server Error
=> true

Strange that it replies “true”…

Does anyone have any idea? Will switching to lighttpd allow me to
avoid this problem?

Thanks for your help,

Paul.

One thing that bit me was in the dispatch.fcgi. Check the first line,
is it pointing to the right spot for ruby? Looks as though your on a
linux environment, so something like ‘/usr/local/bin/ruby’ or where
ever it may be should do the trick.

If thats not it, are any log files getting generated when you try to
start apache? If so which ones?

Also, check to make sure you actually have the requested envirornments
database loaded, if not this leads to weird errors that you wouldn’t
expect (dont ask how I know). :slight_smile: Its probably not an issues as it
looks like you are trying to run in the same env as the webrick
server.

-Nick

One more note, there was another problem I had like this where the 500
error would seem to pop up and random. I also use the SaltedLogin
generator, but I have more then one class/user type that requires
authentication. I had forgot to require the second user type to my
lib/login_system.rb so that when it was getting the information from
the cookies it wouldn’t marshal the objects back out correctly. (took
me a bit to find that one too)

Hope some of this helps!
-Nick