Okay, I wish I could write this now and then go back in time two days, read it, and save myself a lot of hassle. I spent a lot of time trying to debug a rails installation on a shared host and it could have been so much easier.
- Get your Rails app working
- step one
$ chmod 755 public
./public/dispatch.fcgi (or dispatch.cgi – but don’t use that!) also to 755
$ chmod 755 public/dispatch.fcgi
make sure ./public/.htaccess exists (my copy can be found at the bottom of this post)
./log and everything under it needs to be set to 775
$ chmod -R 775 log
do the same for the ./tmp directory (Rails writes session data here)
$ chmod -R 775 tmp
#### step two
Make sure you’re running in ‘development’ mode. Code errors will be displayed to the screen in this mode – but ‘production’ will just barf out on you (it’s intended to work this way).
Set RAILS_ENV=’development’ in config/environment.rb if you have no other way to do this.
$ nano config/environment.rb
#### step three
If the above didn’t work, look at the bottom of any of your log files. Depending what environment you’re in you may need development.log or production.log. If it gives you a handy error like ‘could not find environment.rb’ or something like that it’ll really help you figure out the problem.
$ tail -n 100 log/development.log
#### step four
Get into the ruby console. Try to run a command like you would in your app like User.find_all or something similar. This will show you errors that wouln’t come up elsewhere.
$ ./script/console
- step five If you’re running an app that requires a specific version of Rails but didn’t include it along with the app you’ll need to ‘freeze’ Rails into your app. This is actually quite simple – if you put the whole Rails source code into ./vendor/rails then your application will use that code instead of the stuff on your server at /usr/lib/ruby/ The way to do this is to run any of the following:
rake freeze_gems (get the latest stable version)
rake freeze_edge (get the cutting-edge version)
svn co -r 997 http://dev.rubyonrails.org/svn/rails/trunk
(insert revision number you want instead of 997)
- good luck!
AddHandler fastcgi-script .fcgi
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI
RewriteEngine On
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
ErrorDocument 500 /500.html
#ErrorDocument 500 "Application error
Rails application failed to start properly"
If these steps didn’t work for you leave a comment and I’ll try to help you out. I’m a GNU guy so I don’t know much about Rails on Windows, but I’d be happy to help you avaoid the hideous, hideous Rails errors.
Also, if you’re looking at random 500 errors while working on your Dreamhost account, you’ll want to use a modified dispatch.fcgi file.
35 responses so far ↓
1 Ryan // Jun 05, 2006 at 11:33 AM
2 Danger // Jun 05, 2006 at 03:41 PM
3 Jeff // Jun 10, 2006 at 03:00 PM
4 Danger // Jun 10, 2006 at 03:01 PM
5 MH // Jun 21, 2006 at 08:01 PM
6 Clayton // Jun 23, 2006 at 06:47 AM
7 Clayton // Jun 23, 2006 at 07:35 AM
8 John // Jul 19, 2006 at 12:47 PM
9 Geoff // Jul 27, 2006 at 09:01 AM
10 Yet another Jeff // Aug 07, 2006 at 06:38 AM
11 Adam Roth // Aug 07, 2006 at 07:12 AM
12 random8r // Aug 14, 2006 at 02:04 AM
13 dan // Aug 21, 2006 at 11:58 PM
14 dan // Aug 21, 2006 at 11:58 PM
15 Gustavo // Sep 01, 2006 at 11:51 AM
16 Danger // Sep 02, 2006 at 05:37 AM
17 Evgeniy // Sep 26, 2006 at 02:48 AM
18 prash // Feb 08, 2007 at 02:11 PM
19 Danger // Feb 17, 2007 at 09:45 AM
20 sanjeev // Jul 19, 2007 at 03:40 AM
21 Marcin // Aug 08, 2007 at 04:24 PM
22 Nick // Aug 08, 2007 at 04:25 PM
23 Dayne // Aug 12, 2007 at 06:12 AM
I also had an issue with puts in my Helper code. Thanks to whoever pointed that out. Saved me a headache.
24 j2ibeo // Oct 26, 2007 at 05:21 PM
I am having the Rails application failed to start properly error in Windows environment and XAMPP. Anybody successful on these combo?
25 Josh // Nov 12, 2007 at 08:24 PM
There is a broken link in your article. I think this is the new URL: http://6brand.com/my-dispatch-fcgi
26 Jack Danger // Nov 13, 2007 at 10:08 AM
Thanks for catching that Josh!
The switch from Typo to Mephisto caused a lot of issues like that…
27 Developer // Nov 16, 2007 at 02:30 PM
Thank you so much! I just spent a few hours trying to figure out the problem, and fixing the environment.rb file (as you suggested in step two) did the trick. Thank you thank you thank you!
28 Timo K. // Jan 08, 2008 at 08:21 AM
Thanks a lot for posting this. Has helped me an aweful lot. Cheers!
29 Roger // Jan 15, 2008 at 06:36 PM
with mine cgi worked fine, but fastcgi didn’t—turned out that (one bluehost, at least) they had upgraded, and I needed to change it to AddHandler fcgid-script .fcgi at the top of dispatch.fcgi. Thanks bluehost!
30 Sean // Mar 04, 2008 at 12:51 PM
Thank you so much for sleuthing the .htaccess issues affecting FastCGI. You saved me hours!
31 Octavio // Mar 06, 2008 at 03:29 PM
I’ve been trying all the options here and nothing, I have 2 days in this :( any other ideas?
thank you
32 Jack Danger // Mar 08, 2008 at 01:08 PM
Octavio: It all depends on what error you’re seeing. Is there anything in the log file? Does the app run on one computer and not another? What happens when you try to get into the console?
33 manish // Mar 21, 2008 at 12:20 AM
I have done all the things which u have said but still error is coming. My dispatch.fcgi is running good in my localhost but when i run it in the server it shows the error.
34 Jim // Apr 22, 2008 at 04:24 AM
Hi. Wish i’d found this page about a fortnight ago when i was trying to debug the “Application error Rails application failed to start properly” error page. Production logs showed nothing unusual. It had me proper stumped…. Until the tech support at my hosting compnay pointed out that using puts in your code can cause problems with Apache and i had a ton of them left in from development…... DOH! Bookmarking this for future (headache saving) reference. Thanks
35 Jason // May 08, 2008 at 03:46 PM
Very good article which will be a great help to visitors thank you
Leave a Comment