See the comment at the end before you spend time on this. Pair does not support Rails on their low-cost plans — it’s not that the servers can’t do it. In fact, you can spend time making it work. But Pair’s automated resource monitoring scripts will disable Rails as soon as they notice it, and your time will have been for nothing.
pair Networks 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.
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.
Pair now has a new enough Ruby, but it’s still easier to install your own than to make RubyGems use the existing one.
Don’t try to install Rails in vendor/ to avoid this step. You’ll find yourself unable to install the mysql gem, so mysql won’t work.
First, log in to your Pair shell home directory, and download Ruby using wget:
% wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.4.tar.gz
Now unzip it and untar it:
% tar -xvzf ruby-1.8.4.tar.gz
…and install it into your home directory:
% cd ruby-1.8.4
% ./configure --prefix=$HOME
% make
% make test
% make install
Download, unzip and untar it:
% cd ~
% wget <a href="http://rubyforge.org/frs/download.php/5207/rubygems-0.8.11.tgz">http://rubyforge.org/frs/download.php/5207/rubygems-0.8.11.tgz</a>
% tar -xvzf rubygems-0.8.11.tgz
…and install it:
% cd rubygems-0.8.11
% ~/bin/ruby setup.rb
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)
This dont works on me, here is my way. I use csh, modify $HOME/.cshrc, make sure $HOME/bin is the first one
set path = ($HOME/bin /sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin /usr/X11R6/bin )
%which ruby
%ruby --version
%env
%setenv PATH $HOME/bin:${PATH}
% ~/bin/gem install rails --include-dependencies
Hit enter when asked to accept all the dependencies. If the reaper stops the installation ("Killed"), try an alternating combination of ~/bin/gem install rails and ~/bin/gem update until it succeeds. ~/bin/gem install rails should say “Successfully installed rails-1.1.2”.
% ~/bin/gem install mysql% ~/bin/rails ~/mywebapp
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:
% 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/*
…where {username} is your username. Now we just need to link it to the new directory in your vanity domain.
% rm -r /usr/www/users/{username}/mywebapp
% ln -s ~/mywebapp/public /usr/www/users/{username}/mywebapp
…where {username} is your username.
Reload your site, and with luck, see the “Congratulations, you’re on Rails” screen.
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
What kind of performance can we expect on pair? Has anyone done any comparison between pair and a server for which you can run mod_ruby or FastCGI? Is the performance even acceptable for a somewhat complex application?
—DennisSutch
IMHO, the performance you’ll currently get from a rails app at pair is NOT acceptable for production use.
—LukeMelia
I have an Advanced shared hosting account on Pair.com I have previously installed the current verison of PERL in my shell there that is used to automate some services I created in a cron job. So all the of the advice above seemed authentic. I installed my own version of ruby and my own version of gem.
I wasted about 8 hours trying to manipulate my account to make Rails work with the virtual Apache configuration that is exposed to the account. Finally I sent Pair support this question:
Is Pair going to support Ruby On Rails with the FastCGI Apache module? The only thing I could find in the support docs was an upgrade notice for gems and ruby: http://www.pair.com/support/notices/ruby-php-upgrades.html
I can build Ruby and Gems in my shell, what I really need is the FastCGI module on the web server.
Please point me to any help documents that might already exist.
Thanks Mike
And this was their response:
Hello,
Ruby On Rails and FastCGI are not suitable for the shared web hosting environment. They are allowed on QuickServe dedicated servers, though.
Please let us know if you have any further questions.
—MikeMondragon