Rick Wayne's picture

This is a command-line recipe for getting your Rails 3 apps running on a Turnkey Rails appliance. Be nice to have an automated way to do this, but I have to get back to ACTUALLY WRITING APPS.

Basically the secret to getting it running is to use rvm, and to listen to what rvm is telling you. This installs rvm as the root user, which I figure is fine for a VM.

I was using TKR 11.1-lucid as my base VM.

# Install curl. It's needed to install rvm the easy way. Ignore the error about the java .so:
  apt-get install curl
# Install rvm:
# Install rvm function into root's .bashrc:
   echo '[[ -s "/usr/local/rvm/scripts/rvm" ]] && . "/usr/local/rvm/scripts/rvm" # Load RVM function' >> ~/.bashrc
# Reload:
  . ~/.bashrc
# Install 1.9.2 under rvm:
  rvm install ruby-1.9.2
# Make it the default:
  rvm use ruby-1.9.2 --default
# Change to it (although the --default line probably does this):
  rvm use ruby-1.9.2-p(patchlevel)
# Gemset for Rails 3:
  rvm gemset create rails3
# Use that gemset:
  rvm gemset use rails3
# (Re-) Install Rails:
  gem install rails -v=3.0.1
# (Re-) Install Passenger:
  gem install passenger
# Install the necessary prerequisite library:
  apt-get install libcurl4-openssl-dev
Compile and install the Passenger module. First you have to find the version of Passenger that you just installed (which is in a different place from the one preinstalled in the appliance):
  find /usr/local/rvm -name passenger-install-apache2-module
Two paths will appear, one of them in bin and the other one in gems. Take the shorter one and copy it. For my system, the two paths were:
Run that script:
IMPORTANT: Grab the configuration lines at the end of the passenger install process! If you just use the default Passenger LoadModule, PassengerRoot, and PassengerRuby lines the GEM_HOME and paths won't be set up correctly, and you'll run into issues like "bundler: cannot load file". For my system, those lines were:
  LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.8/ext/apache2/mod_passenger.so
  PassengerRoot /usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.8
  PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.2-p290/ruby
In /etc/apache2/conf.d/passenger, replace the three corresponding lines with the new stuff you copied.
Set up your Rails application in /var/www/railsapp, do a bundle install, restart Apache (/etc/init.d/apache2 restart), and you're golden!
Feel free to contact me (f e w a y n e 'at' w i s c 'dot' e d u) if I've goobered something.

Add new comment