Ruby on Rails
HowToInstallOnSite5

Site5 now offers ruby on rails support on its servers, this is a quick how-to on getting a Rails app running.

  1. First, you will need SSH access to your account, you can enable it in the siteAdmin → Advanced Tools → Get Shell access. You will also need an SSH application such as Putty.
  2. Now, login to your account using SSH and navigate to your home directory.
    
    cd ~
    
  3. Next create/update your Rails application by typing:
    
    rails appname
    
  4. Now, you will need to create a symbolic link to the public directory of this app. This will make it accessible on the web server.
    
    ln -s ~/appname/public ~/public_html/appshortname
    
  5. You will now be able to access your Rails app at http://yourdomain.com/appshortname/
  6. If you have already developed your website on your computer, use FTP to upload the following folders: app, public, config and db/migrations. You may want to freeze your app so that you will not have any version conflicts with the site5 installation of rails (1.1.6). To do this, from the root of your project, run ‘rake freeze_gems.’
  1. If you want your Rails application to be accessible from the root directory, you can do the following. Only try this if you don’t have any other content in your public_html directory
    mv public_html public_html_back
    ln -s ~/appname/public ~/public_html
    
  2. Make sure your shebang lines in dispatch.cgi and dispatch.fcgi (in the public folder) are pointing to the correct Ruby installation
    #!/usr/bin/ruby
    
  3. Remember to run your DB migration
    export RAILS_ENV=production
    rake db:migrate -t
    

Going into Production Mode with FCGI

  1. Edit your .htaccess file in the /public/ directory with the last Rewrite rule pointing to dispatch.fcgi
    RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
    
  2. Edit your environment.rb in the /config/ directory, uncomment line 5 or what looks like
    ENV['RAILS_ENV'] ||= 'production'
  3. Restart your FCGI Processes at the shell prompt
    killall -9 dispatch.fcgi
    

Troubleshooting

  1. If you are still in failure mode:
    Run dispatch.cgi from the command line (using ./dispatch.cgi). This is the best tip I think for people who have the same ‘Application Error’ line as me. Doing this will actually tell you what is failing in dispatch.cgi instead of the error logs just telling you it failed.
  1. If you’ve created a new account on Site5 (via a reseller account) and are trying to view the site before it has had the nameservers changed by going to www.main-account.com/~subaccount_username/, symbolic links will not work, due to how Site5 has apache set up. You can work around this (linux guys) by adding an entry to your /etc/hosts file that links your main-account IP address with the subaccount’s domain. This makes apache associate the request with the right account.
  1. If you have also installed your own gems, include the new gem path at the top of your environment.rb file
    ENV[‘GEM_PATH’] = ’/home/username/gems:/usr/lib/ruby/gems/1.8’
  1. Additional help when debugging issues with dispatch.fcgi can be found by running it using the ruby environment in debug mode.
    ruby --debug dispatch.fcgi
    
    External links