Analyze. Act. Achieve.
Kurinchilion KURINCHILION Analyze. Act. Achieve.

Articles

How to install Ruby, Rails and MySQL on Ubuntu Server?

For this tutorial we will be using Ruby 1.9.3 and Rails 3.2.1

First thing update $ sudo apt-get update

Next, we are going to install git, RVM which is essential for the build

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

RVM stands for Ruby Version Manager that is used for installing and managing multiple versions of Ruby at one point of time.

$ curl -L get.rvm.io | bash -s stable

To load RVM into bash, type in

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

$ source /etc/profile.d/rvm.sh

Reload bashrc by issuing the command

$ . ~/.bashrc

Check rvm requirements

$ rvm requirements

Load all packages that are necessary to be loaded for Ruby to run

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

Install RVM

$ rvm install 1.9.3

To use RVM, type

$ rvm use 1.9.3

To know the version of Ruby that is installed type

$ ruby -v ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]

To make the Ruby the default version for the user

$ rvm --default use 1.9.3-p194

Install rails by typing

$ gem install rails -v 3.2.3

$ rails new [project name]

$ rvm use 1.9.3-p194@rails3 --rvmrc

You can install MySQL or SQLLite. In this tutorial we will be installing MySQL

$ sudo apt-get install mysql-server mysql-client

$ sudo apt-get install libmysql-ruby libmysqlclient-dev

$ sudo gem install mysql