Set up new Slicehost with Ruby and Rails

by Michael McClenaghan 2008-03-02

OK, this one is going to be all technical.

I signed up with SliceHost a while back but recently decided to re-image my slice. The plan is to go with a Ubuntu Dapper Drake 6.06 LTS image since that seems to have the most documentation for Rails stuff. This is mostly Greek to me so this installation list is a good way for me to keep track of everything for the future.

References

  • http://wiki.neeraj.name/slicehost/published/HomePage
  • http://hivelogic.com/articles/ruby-rails-leopard/
  • http://ubuntuforums.org/showthread.php?t=649881
  • http://codersifu.blogspot.com/2007/03/howto-install-ruby-in-ubuntu-edgy-610.html

Steps

    ssh root@x.x.x.x                       # insert IP address here
    adduser --ingroup users myusername     # pick something nicer than 'myusername'
    visudo

Go to the end of the file and add the following line:

    myusername ALL=(ALL) ALL

And save the file. Logout and then back in with the new username.

Bring the slice up to date with the following commands:

    sudo apt-get update
    sudo apt-get dist-upgrade
    #Restart the slice
    sudo shutdown -r now

We're going to deviate from apt-get here a little bit so that we can install the latest and greatest version of Ruby from rubyforge. Before grabbing Ruby, we need to install a few tools and create a directory for our source files first:

     sudo apt-get install build-essential curl
     mkdir /home/myusername/sources
     cd /home/myusername/sources

To use Ruby 1.8.6, you have to install it manually instead of using apt-get. Here's the steps:

    curl -O ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p111.tar.gz
    tar xzvf ruby-1.8.6-p111.tar.gz
    cd ruby-1.8.6-p111
    ./configure --prefix=/usr
    make
    sudo make install
    sudo ln -s /usr/bin/ruby /usr/local/bin/ruby
    cd ..

Now when you type:

ruby -v

You should see:

ruby 1.8.6 (2007-09-24 patchlevel 111) [x86_64-linux]

Now that Ruby is installed, Ruby Gems can be installed. Everything is much easier after this.

    curl -O http://files.rubyforge.mmmultiworks.com/rubygems/rubygems-1.0.1.tgz
    tar xzvf rubygems-1.0.1.tgz
    cd rubygems-1.0.1
    sudo ruby setup.rb
    sudo gem update
    cd ..

That's it. A bit of a pain but at least everything is set up and good to go. The next step is to get Rails and Mongrel installed. After that, Apache, mongrel clusters and MySQL need to be setup. Finally, things should be ready for Capistrano!

blog comments powered by Disqus