Hi! Thanks for visiting my blog. If you've received any value from my content would you mind supporting my new startup by downloading our browser add-on? It's called PriceBlink and makes online shopping a breeze. You can watch it in action here and download it for Chrome, Firefox, IE, or Safari by going to PriceBlink.com. Thank you and I hope you enjoy!

Tips for Running Rails on GoDaddy Servers

Jun 04

I’ve spent the last 10 days emailing back and forth with GoDaddy’s technical support team on my Rails configuration. It has been insanely frustrating, but they’ve been very responsive. The frustrating part has been the fact that they’ll make a suggestion such as “change the permissions on dispatch.cgi” and get me one step closer to a working app, but I’ll have to contact them again because something else is broken. At any rate, I’m pleased that my app is running and I wanted to post what you should know here, since I couldn’t find anything in their help docs.

Since most of my Rails development is done with the WEBrick server I ran into a few problems with GoDaddy’s configuration.  They claim to be using FastCGI, but from what I can tell it appears to be plain old cgi.  At least that’s the binary that appears to be executing.  So you should make sure of the following:

1. The first line in dispatch.cgi should point to /usr/local/bin/ruby so it should look like #!/usr/local/bin/ruby.
2. Make sure to set the permissions on dispatch.cgi to 755.

Now that should get your app running assuming you have no database integrated.  If you’re looking to hook up to MySQL then you need to make sure your database.yml config file is setup correctly.  Make sure it looks something like the following:

production:
adapter: mysql
host: mysql.domain.net
port: 3306
database: dbname
username: uname
password: pwd

By default Rails assumes the database server is running locally and with GoDaddy the database is generally on another server.  Therefore you need to specify the host and port parameters in the config file.  Once you get this config setup you should be good to go.  I know this doesn’t seem like a whole lot of work, but that’s easy to say once you’ve been told what the problem is.  If you’re hosting with GoDaddy then this could help you save a lot of time and even some hair.

15 comments

  1. Zach /

    Using your tips above I was also able to get a ruby app up and running after battling with GoDaddy’s tech support for over a week.

    Anyway, they support CGI and FastCGI, and supposedly switching between the two is as easy as ensuring that the #!/usr/local/bin/ruby line is within the dispatch.fcgi file and that the RewriteRule ^(.*)$ dispatch.cgi [QSA,L] in the [app]/public/.htaccess file is changed to RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]. This seems to work as the loading times on my pages improve significantly. I don’t think the .htaccess file in the application’s root directory even has any bearing on how the actual app performs.

    I do get a problem though when switching to FastCGI, that being after one or two writes to the database (also hosted on GoDaddy), I begin receiving “Application error (Rails)” messages. Here is the snippet from the production log when the error occurred:

    —————————
    ArgumentError (wrong number of arguments (2 for 0)):
    /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1641:in `quote’
    —————————

    Again, this doesn’t occur when using CGI, just FastCGI. I don’t believe it’s anything wrong with the code since I can pull off one or two database modifications (updates/deletes) before this error begins occurring. To get database modification to work at all after this I have to switch back to regular CGI.

    When monitoring the processes within the CGI Administration utility, I do notice something odd, that being that two (sometimes three) dispatch.fcgi processes run at the same time and continuously. I can’t even kill them via the CGI Administration utility. Eventually they use less and less CPU and eventually just drop off the list. I’m not sure if this is related to the above errors or not.

    Again, it’s quite possible that I have another setup issue that I just can’t see that’s causing the error. You seem to have had a better experience with GoDaddy support than I as every time I’ve asked for support I receive something along the lines of “Unfortunately, we are very limited in the support we can offer for customer-written code or scripts such as this. If there is evidence that our system is responsible for the error – and, I’m afraid, we need more than “it works elsewhere” – please forward it to us, and we would be happy to look into the matter further. But at the moment this does not yet appear to be the case, so we regret we can not currently assist you with this issue. We apologize for any inconvenience this may cause.”

    Thanks for the tips so far, and at least I’ve got something up and running, even if it is very slow. I’d be interested to see if you experience the same issues switching to FastCGI, or if this issue is specific to my setup.

  2. Zach,

    Thanks for the great feedback and I’m definitely planning on giving FastCGI a go. I appreciate the tip and I’ll let you know how it goes. It’s very strange you’re getting app errors after a few writes to the db. That sounds very quirky and I’m hoping not to run into the same problem. I know with standard CGI I have no problems writing to the db and will test with FastCGI.

    Thanks again,
    Dennis

  3. Zach /

    Turns out my issue was usincg a reserved word in Ruby (quote) as a column name, having ActiveRecord freak out and simply stall out the fcgi session. I plan on fixing this later tonight, but it seems that a simple modification to the .htaccess file should have you up and running on fcgi.

  4. I can’t stand running into reserved word conflicts. It’s generally a couple hours later when you realize that it’s not a code issue, but a reserved word. I was able to successfully get FastCGI working on GoDaddy and am completely amazed with the performance of the app. It’s night and day compared to standard CGI. Thank your for the pointers :)

  5. I’m not having any luck. I’ve done the above and its still not working. However, its almost like godaddy isn’t even seeing my updates. Here’s my logs. Do I have to do anything special to notice the directory on godaddy? I named it the same as my project sdlifecycle. Any thoughts?

    [Thu Jul 13 18:11:08 2006] [error] [client 67.190.252.75] File does not exist: /var/chroot/home/content/d/g/e/dgermundson/html/phase/homepage
    [Thu Jul 13 18:11:14 2006] [error] [client 67.190.252.75] File does not exist: /var/chroot/home/content/d/g/e/dgermundson/html/phase/homepage.rhtml
    [Thu Jul 13 18:11:17 2006] [error] [client 67.190.252.75] File does not exist: /var/chroot/home/content/d/g/e/dgermundson/html/phase
    [Thu Jul 13 18:11:19 2006] [error] [client 67.190.252.75] File does not exist: /var/chroot/home/content/d/g/e/dgermundson/html/phases

  6. You shouldn’t have to do anything special. Just make sure you create a symbolic link in the CGI control panel. This should be done after you create the app directory. The symbolic link will actually be the path to the application. So if you’ve created an app with a symbolic link of “myapp” then it will be accessed via http://mydomain.com/myapp which maps to the Rails public directory. If you can give me some more info I’ll be glad to help you dig into this further. Please feel free to email me at dennisbaldwin at gmail dot com. Good luck.

  7. chris /

    I had the typical problem running my RoR app on godaddy, where I would get, “Rails app failed to start properly”.

    My problem turned out to be the Rails Gem Version.

    GoDaddy supports 1.0.0, so I set this in my environments/production.rb:

    RAILS_GEM_VERSION = ’1.0.0′

    Add that to the list of things to consider when troubleshooting.

    Thanks for all the other comments that helped me with my environment.

  8. Chris,

    I appreciate the comment. I too had to roll back my version variable to 1.0.0 since my Rails dev environment is 1.1.2. I completely forgot to post that here and I appreciate the reminder.

    Regards,
    Dennis

  9. I’m also struggling with Rails on GoDaddy. I’ve followed all the comments here on this thread and I’m now getting to my public/index file and it displays the “Welcome aboard” page Rails generates. What I’m not getting is how do I get it to recognize my app? When I go to http://www.physiciandirectservices.com/schedprog/login/, I get a long delay and I get the following message in Safari:

    Safari can’t open the page “http://www.physiciandirectservices.com/schedprog/login/login/”. The error was: “lost network connection” (NSURLErrorDomain:-1005)

    I get nothing but a blank screen in Firefox.

    I have no clue what’s causing this. Any ideas?

    Dave

  10. Dave,

    Have you checked your production.log file to see what it says? There have been numer of times I’ve been able to access my rails index page, but none of the controllers in my app for one reason or another. You might just be running into the problem where GoDaddy’s servers are too loaded to respond to the request. I get a 404 when trying to access the link above. Are you still having problems or did you get it resolved?

    Regards,
    Dennis

  11. Thanks very much!!!

    Using this article I was able to install “Tracks” http://www.rousette.org.uk/projects/

    on my website

    You Rule!

  12. Niall Doherty /

    I’m having the same problem as Dave above. I can get the “Welcome aboard” page when i go to “www.mydomain.com/myapp/”, but trying to load up the actual app beyond that just leaves me with a blank page and no source code in IE, FF and Opera. I’m so pissed off at this point that I’m close to dumping GoDaddy and switching to Dreamhost.

    I checked my production.log file too, and that’s blank, so no help there I’m afraid. Anyone got any other suggestions?

  13. Niall,

    Personally I think you should dump GoDaddy. I hate to say that, but I’m so much happier now on Rails Playground. Bluehost wasn’t bad either.

    Okay to answer your question have you tried turning on your CGI error logs in the GoDaddy admin? Sometimes you have to do this and wait a few minutes before logging begins. Logging on GoDaddy is completely quirky.

    Take care,
    Dennis

  14. Hi All.
    I am a developer working for Ruby On Rails project. I am trying to
    deploy my ruby project on godaddy shared server, but i am unable to
    browse the application and i am not getting any help from the support
    team of hosting server. Can any one help me to solve the problem. It
    would be grateful for me if anyone suggest me what to do.

    Thanks in advance for your help

  15. hamaky /

    check out this article, hope it solves your problems with godaddy

    http://www.bigbluebrains.com/index.php/2010/08/04/how-to-host-a-ruby-application-on-godaddy/

Trackbacks/Pingbacks

  1. [db75] » Blog Archive » Running Rails with FastCGI on GoDaddy Servers - [...] Zach recently posted a comment about configuring Rails to work with FastCGI on GoDaddy servers.  By default GoDaddy has ...

Leave a Reply