Install RVM, Git, Ruby and Ruby on Rails, MySQL on Ubuntu

The first step is to install some dependencies for Ruby. (Run following command to the terminal)

sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev

Install ruby using RVM (Ruby Version Manager) (Run following command to the terminal)

sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm install 2.3.1
rvm use 2.3.1 --default
ruby -v

The last step is to install Bundler (Run following command to the terminal)

 gem install bundler

Install a Javascript runtime (NodeJS) (Run following command to the terminal)
To install NodeJS, we’re going to add it using the official repository:

 curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
 sudo apt-get install -y nodejs

Installing Rails (Run following command to the terminal)

gem install rails -v 4.2.6

Setting Up MySQL
You can install MySQL server and client from the packages in the Ubuntu repository. As part of the installation process, you’ll set the password for the root user. (Run following command to the terminal)

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

This will ask you to enter password of MySQL root user. Type password for root user and press enter.

Also you can give the password of root user directly command line. For this:

sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password your_password'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password your_password'
sudo apt-get -y install mysql-server mysql-client libmysqlclient-dev

Here your_password is the password of your MySQL root user.

Here is a slide which helps to install Ruby and Ruby on Rails using RVM in ubuntu.

2Shares