"pair Networks":http://pair.com/ is a popular host, with good reason: they're cheap, reliable, and fairly geek-friendly. But unfortunately, they're conservative with new tools, and don't yet support Ruby on Rails. The good news is that you can install it yourself.

These instructions are tailored for pair, but they should serve as a good template for getting Rails on other hosts that don't have the latest Ruby installed.

h3. Set up a new domain from the Account Control Center.

Map the new domain to a subdirectory of your web directory. For this example, we'll make the directory called "mywebapp".

Go to sleep and wake up 24 hours later. Make sure the new domain works.

h3. Install a newer Ruby

Pair's installed version of Ruby is 1.6.8 -- too old to run Rails. We'll have to install the latest version.

First, log in to your Pair shell home directory, and download Ruby using _wget_:

<pre><code>% wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.2.tar.gz</code></pre>

Now unzip it and untar it:

<pre><code>% tar -xvzf ruby-1.8.2.tar.gz</code></pre>

...and install it into your home directory:

<pre><code>% cd ruby-1.8.2
% ./configure --prefix=$HOME
% make
% make test
% make install</code></pre>

h3. Install RubyGems

Download, unzip and untar it:

<pre><code>% cd ~
% wget http://rubyforge.org/frs/download.php/3700/rubygems-0.8.10.tgz
% tar -xvzf rubygems-0.8.10.tgz</code></pre>

...and install it:

<pre><code>% cd rubygems-0.8.10
% ~/bin/ruby setup.rb</code></pre>

check your path - the default Pair path will point you to the 1.6.8 version of ruby which will cause gem to fail to run (gem starts with #!/usr/bin/env ruby)

h3. Install Rails

<pre><code>% ~/bin/gem install rails</code></pre>

Hit enter when asked to accept all the dependencies. If the reaper stops the installation ("Killed"), try an alternating combination of <code>~/bin/gem install rails</code> and <code>~/bin/gem update</code> until it succeeds. <code>~/bin/gem install rails</code> should say "Successfully installed rails-0.11.1".

h3. Create a new Rails application

<pre><code>% ~/bin/rails ~/mywebapp</code></pre>

Rails should create a new directory called "mywebapp" where your application will live. Now we'll fix the she-bang lines to point to our new Ruby installation:

<pre><code>% cd ~/mywebapp
% ruby -e 'my_ruby = "/usr/home/{username}/bin/ruby" ; lines = nil ; ARGV.each { |filename| File.open( filename, "r+" ) { |file| lines = file.readlines ; lines.each { |line| line.sub!( /^\s*#!\/usr\/local\/bin\/ruby/, "#!" + my_ruby ) } ; file.rewind ; file.print( lines.join( "" ) ) } }' public/dispatch.{cgi,fcgi,rb} script/*</code></pre>

...where {username} is your username. Now we just need to link it to the new directory in your vanity domain.

<pre><code>% rm -r /usr/www/users/{username}/mywebapp
% ln -s ~/mywebapp/public /usr/www/users/{username}/mywebapp</code></pre>

...where {username} is your username.

Reload your site, and with luck, see the "Congratulations, you're on Rails" screen.

h3. Start building

Edit config/database.yml to point to your database, create some tables, and use @script/generate@ to create some scaffolding.

Step 31: There is no step 31!

--ScottRaymond

category:Howto
