Set Up Ruby on Rails at Linux Ubuntu Using RVM

I’ve been telling you a lot about Ruby on Rails but have I told you about how to set it up on your machine? Not at all. This is my chance to share my experience to you, but this time I’ll tell you about how to set it up on Ubuntu 10.04 (Lucid Lynx) or Ubuntu 11.04 (Natty Narwhal).  The setup on these two OS is similar, so you don’t have to be confused about the version difference of Ubuntu. Now, let’s get into the point, these were the steps that I did :

  1. Update the packaging tool repository (apt) just to make every download fast. You can do it by changing the file in /etc/apt/source.list
  2. Please install some initial package that are needed for some action, by running this command :
    sudo apt-get install build-essential openssl libreadline5 libreadline-dev git-core curl zlib1g zlib1g-dev
  3. Now let’s install RVM, by running this command :
    bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
  4. Go to your home directory (cd ~) and open up file .bashrc by running : vim .bashrc
  5. Please add this code inside the file :
    [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
  6. Now please close the terimnal and open it again to make the changes happened
  7. Next is ruby installation. I used REE, so I will show you how to install it. You can do it by running this command :
    $> rvm install ree
    $> rvm --default ree
  8. Okay, your ruby has been installed and next is phusion passenger and application server installation. I used Nginx as my application server, so I did this to install those two things :
    $> gem install passenger
    $> rvmsudo passenger-install-nginx-module

    I used the default settings, so I just enter everything that prompted me. When you do this, you may find that you have to install somethings first. But it’s okay, because you will be shown what you have to do to install it. By running this command, you will also install the nginx. So you don’t have to worry about the nginx installation itself.

  9. I like using PostgreSQL as my RDBMS, so next is postgresql installation. Do it by running these command :
    $> sudo apt-get install postgresql
    $> sudo -u postgres psql postgres #this command will bring you to postgre console
    \password postgres #this command is used to change password for user postgres. You will be prompted to enter new password. After that, quit the console.
    $> sudo apt-get install libpq-dev
  10. This is the main action, Ruby on Rails installation! Run this command to install it :
    sudo gem install rails
  11. Later in the development, I like to use Paperclip which is need ImageMagick and RMagick Gem installation. But first, let’s install the imagemagick.
    $> sudo apt-get install libjpeg62-dev
    $> sudo apt-get install libpng12-dev
    $> sudo apt-get install imagemagick
    $> sudo apt-get install libmagick9-dev
  12. You imagemagick has been installed and next, install rmagick. Do it by running these command :
    $> sudo gem install rmagick
    $> irb -rubygems -r RMagick #this will lead you to ruby console
    puts Magick::Long_version #if you can see the version of RMagick after you run this command, that means the installation is successful
  13. To simplify your job to install gems in your Gemfile, you can use bundler. Install it by running :
    sudo gem install bundler

That’s it, you have successfully installed Ruby on Rails on your Ubuntu. I hope this could help you doing it.

Enjoy!

Advertisements

One thought on “Set Up Ruby on Rails at Linux Ubuntu Using RVM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s