A little birdie told me that Godaddy supports Ruby On Rails Applications. This little birdie, however, did not sing me the whole song. Soon after, I was on the phone with Godaddy support to see if we could get a demo app up and running. No such luck! While ROR is supported, unfortunately Godaddy support staff is totally clueless on how to get it to work. I set about troubleshooting and this is what I found.
This method (currently) requires the domain to point to your application’s public folder. So it doesn’t work for a setup like http://www.example.com/rails-app/controller/action. When I get around to it, I plan to create an example of that as well.
Of course, you have to go through some of the normal steps for ROR staging. Namely, creating a production version of your database, and freezing your application.
# CREATE A PRODUCTION DB VIA COPY FROM THE DEVELOPMENT VERSION
cp db/development.sqlite3 db/production.sqlite3
# FREEZE YOUR APP
rake rails:freeze:gems
# TEST AS PRODUCTION
script/server -e production
When you put your app on Godaddy, you have to tell the Apache webserver to route all requests to your Rails application. Keeping in mind that we’re using shared hosting, the easiest way to take care of this is via .htaccess saved as public/.htaccess
echo 'AddHandler fastcgi-script .fcgi
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI
#
# BEGIN Ruby on Rails Application
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /dispatch.fcgi [L]
</IfModule>
# END Ruby on Rails Application' > public/.htaccess
This also adds the .fcgi handler, which allows you to use dispatch.fcgi instead of dispatch.cgi only. In fact it may supplant the need for the dispatch.cgi file, but I haven’t tested that yet.
In OS X I can just right click and select “Create Archive of…” For Windows I think it’s right-click and select “Send to > Compressed Folder”.
Your development system my have a different location for Ruby than Godaddy. So, make sure your have the correct shebang on the correct system. The following files are the ones you need to pay attention to.
Replace:
#!/opt/local/bin/ruby
#
With
# - old !/opt/local/bin/ruby
#!/usr/local/bin/ruby
#
Frankly, I haven’t really seen a performance difference. But it seems like the right thing to do. Update the dispatch.rb file so that it includes the frozen dispatcher file instead of searching for the system version of the file.
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
require File.dirname(__FILE__) + "/../vendor/rails/railties/lib/dispatcher.rb"
Please note that this technique is in it’s alpha stage. There’s not a good way to automate the process. Nor is the process particularly well documented. Also, shared hosting on Godaddy is not particularly fast, but it is cheap!
« PHP Class: KeyValueTextBlock « Previous Article
Next Article
The contents, design, and development of this site are all done by me, Ethan Kent.
The contents of my site, ethanmultimedia.com, are for general information only and provided strictly as is. I do my best to be truthful and accurate, but I must expressly disclaim any implied warranties of non-infringement, merchantability and fitness for a particular purpose. Browse this site at your own risk. If you’re looking for safety and assurance you should probably seek the advice of an appropriate professional.