[Ruby on Rails] CGI works, FCGI doesn't, no error

software development



I’ve got a problem with a very basic Rails application.
Everything works just fine when i use dispatch.cgi in the .htaccess file.
But when i use dispatch.fcgi the application just keep loading and nothing appears.

This is the .htaccess i uploaded in /public:

RewriteEngine On RewriteCond %{REQUEST_URI} ^/stats/(.*)$ [OR] RewriteCond %{REQUEST_URI} ^/failed_auth.html$ RewriteRule .* - [L] RewriteRule ^$ index.html [QSA] RewriteRule ^([^.] )$ $1.html [QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]I checked this page:http://convergentarts.com/pages/fastcgi and uploaded the fcgi_handler to the /lib folder.
The shebang line i use in dispatch.cgi and dispatch.fcgi is: #!/usr/bin/ruby1.8 because that’s the only one that works.

I tried: “killall -9 dispatch.fcgi” and “killall -9 dispatch.cgi” but it returns: “no process killed”

Everything is set up correctly in the config and everything is correctly chmodded (also did: dos2unix dispatch.*).

I followed these guidelines: http://wiki.rubyonrails.com/rails/pages/TutorialStepOne
You can see it at http://test.joostbovee.com/friends/view/

Can someone help me please?



What do the logs say?


I’m not sure what log i need to check, but the error.log is empty and so is the access.log (for the test.joostbovee.com subdomain).

The app not working isn’t really the problem, the problem is that the app just keeps loading and nothing appears.

I would be very happy with some kind of an error message.


Look at the logs in the /yourrailsapp/log/production.log

That might have something in it.


The production.log says: nil.

The fastcgi.crash.log says:

# Logfile created on Fri Dec 09 07:47:12 PST 2005 by logger.rb/ [09/Dec/2005:07:47:12 :: 1943] starting [09/Dec/2005:07:47:13 :: 1943] terminated gracefully Development.log (i run the app in development mode) says the following when i run the app in normal CGI (not FCGI):

Processing FriendsController#view (for at 2005-12-09 07:49:04) [GET] Parameters: {"action"=>"view", "controller"=>"friends"} [4;36;1mPerson Load (0.000762)[0m [0;1mSELECT * FROM people WHERE (people.id = 1) LIMIT 1[0m Rendering friends/view [4;35;1mPerson Columns (0.000648)[0m [0mSHOW FIELDS FROM people[0m Completed in 0.21600 (4 reqs/sec) | Rendering: 0.01506 (6%) | DB: 0.00141 (0%) | 200 OK [test.joostbovee.com/friends/view/] So you see that the app runs correctly in cgi mode.

I ran the app on localhost (with the Webrick server) with fcgi and that worked just fine.

I’m still very new to Rails, but i want to learn how to build my web-app’s in Rails.
So I really hope anyone can help me out here.


What happens when you run it in Production mode? I ask because running in Development mode should be limited to running it locally. Dev mode can spawn a number of processes and eat up memory (which makes Dreamhost sad).


Changing it to: ENV[‘RAILS_ENV’] = ‘Production’ gives the following error:

[code]Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@test.joostbovee.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request. [/code]This happens when the public folder is chmodded 775
When i chmod it to 755, the same problem occurs (no error, just enless loading).

Running dispatch.fcgi in the shell gives this message:

/usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/initializer.rb:150:in `read': No such file or directory - ../config/../config/environments/Production.rb (Errno::ENOENT) from /usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/initializer.rb:150:in `load_environment' from /usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/initializer.rb:147:in `silence_warnings' from /usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/initializer.rb:147:in `load_environment' from /usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/initializer.rb:78:in `process' from /usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/initializer.rb:40:in `send' from /usr/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/initializer.rb:40:in `run' from ./../config/environment.rb:9 from dispatch.fcgi:22:in `require' from dispatch.fcgi:22

  • Bump *

Anyone, please ?

I tried everything i could think of so i’m pretty much stuck here.


You want to set the environment to be ‘production’, not ‘Production’. Alternatively rename the file in config/environments, but I think that would be the wrong way to go about it.



Changed it to: ENV[‘RAILS_ENV’] = 'production’
Still doesn’t work.

I set up another domain with the exact same app, only this time is use .cgi in the .htaccess file.

See: http://test2.joostbovee.com/friends/view/

Edit: It works!!!
I did nothing and suddenly it worked, very weird.