DivineRails

Ruby on Rails

Blog

Installing RVM, Ruby, Rails and MySQL on Ubuntu

Posted by Rq Bukhari on January 7, 2012 at 2:05 PM




This guide will help you install and set up ruby 1.9.2, RVM, Rails and MySQL on Ubuntu machine. If you are not using Ubuntu then don't try this method to install rails.



RVM


Before starting the installation we will run the sudo apt-get update command so that we have the latest sources. After this the first step is to install Git, curl and build-essential. These packages are required for installing and using RVM. To install these we use the command:


sudo apt-get install build-essential git-core curl


After installing these packages we will install RVM. RVM is Ruby Version Manager created by Wayne E. Seguin. RVM is extremely helpful for installing and managing many different versions of Ruby. Sometimes we need to work on different versions of Ruby in projects so RVM is best for managing different versions of Ruby. We will install RVM with this command:


bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)


After installation we need to load RVM by using this command:


echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] &&source "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc


Once loaded and ~/.bashrc is added to the line, we can reload the ~/.bashrc by this simple command:


. ~/.bashrc


The next step is to know about the packages we need to install for Ruby to work. Here is the command that will tell us about the packages that we need to install:


rvm requirements


The command will show different packages that we need to install. We will install the packages using this command:


sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion


To install all the packages this command must be written on a single line, otherwise some of the packages will not be installed.



Ruby


Now the installation of RVM is completed so we can easily install any version of Ruby by using this simple command:


rvm install 1.9.2


This command will take some time and will install the mentioned version of ruby. After the installation we must tell RVM to make our required version as default and useable for us. We will use the command:


rvm --default use 1.9.2



Rails


Now RVM and Ruby is installed the next step is to install Rails. We will use the simple command:


gem install rails -v 3.0.10


We will not use sudo to install rails because RVM is installed in our home directory.



MySQL


Now the installation of Rails is completed and we will install MySQL. Before installing MySQL gem we need to install libmysqlclient-dev package. We will use the command:


sudo apt-get install mysql-server mysql-client libmysql-ruby libmysqlclient-dev


After installing these packages we will install MySQL gem by using this simple command:


sudo gem install mysql

 

Now our installation is complete. If anyone has any question, you can ask here. RVM is very powerful tool and it comes in handy for Ruby development. It’s better to use RVM instead of the packages from apt.

Categories: None

Post a Comment

Oops!

Oops, you forgot something.

Oops!

The words you entered did not match the given text. Please try again.

Already a member? Sign In

2 Comments

Reply nhia
11:09 AM on January 28, 2012 
BEST RVM INSTALLATION GUIDE EVER. I tried the other RVM installation tutorial and all I encounter was unexpected *******. Thank you for the short and simple guide.

Note: This command is out of date " bash
Reply Rq Bukhari
5:43 AM on February 2, 2012 
nhia says...
BEST RVM INSTALLATION GUIDE EVER. I tried the other RVM installation tutorial and all I encounter was unexpected *******. Thank you for the short and simple guide.


Thanks for your comment and liking the post. I'll provide posts about rails technology soon. You will enjoy and gain a lot of knowledge and information about ruby on rails development here on divinerails.

Keep smiling. :)