Installation Guide: Ruby On Rails on Ubuntu 14.04

Are you ready to dive into Ruby On Rails development on your Ubuntu 14.04 system? This comprehensive installation guide will walk you through the process, step by step, from installing Ruby and Rails to configuring Git and setting up MySQL.

Ruby On Rails

Introduction

Ruby On Rails (Rails) is a popular web application framework that allows you to build powerful and dynamic web applications with ease. To get started with Rails development on your Ubuntu 14.04 machine, follow this guide.

Installing Ruby

RVM (Ruby Version Manager) is a powerful tool for managing multiple Ruby versions on your system. Let’s start by installing Ruby using RVM.

# Update your package manager first:
$ sudo apt-get update

Install the necessary dependencies for Ruby:

$ 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

Additional dependencies:

$ sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev

To get the RVM signature, run:

$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

If it fails, use the following commands:

$ command curl -sSL https://rvm.io/mpapis.asc | gpg --import -
$ curl -L https://get.rvm.io | bash -s stable

Now, you can install Ruby (e.g., version 2.1.2) and set it as the default:

$ rvm install 2.1.2
$ rvm use 2.1.2 --default

Check the installed Ruby version:

$ ruby -v

Configuring Git

Git is essential for version control. Configure Git with your name and email:

$ git config --global color.ui true
$ git config --global user.name "YOUR NAME"
$ git config --global user.email "YOUR@EMAIL.com"

Generate an SSH Key:

$ ssh-keygen -t rsa -C "YOUR@EMAIL.com"

Add the public key to your GitHub account by copying the content of ~/.ssh/id_rsa.pub to https://github.com/settings/ssh.

To check if it worked, run:

$ ssh -T git@github.com

You should see: “Hi excid3! You’ve successfully authenticated, but GitHub does not provide shell access.”

Installing Rails

To install Rails, we also need to install a JavaScript runtime like NodeJS:

$ sudo add-apt-repository ppa:chris-lea/node.js
$ sudo apt-get update
$ sudo apt-get install nodejs

Install Rails using RubyGems:

$ gem install rails

Check the installed Rails version:

$ rails -v

Setting Up MySQL

To set up MySQL for your Rails applications, run the following commands:

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

Installing libmysqlclient-dev provides the necessary files to compile the mysql2 gem, which Rails uses to connect to MySQL when setting up your Rails app.

Now, you’re all set to start building amazing web applications with Ruby On Rails on your Ubuntu 14.04 machine. Happy coding!

Summary

In this installation guide, we covered the following topics:

  • Installing Ruby with RVM
  • Configuring Git and setting up an SSH key for GitHub
  • Installing Rails and a JavaScript runtime
  • Setting up MySQL for Rails development.

Follow these steps, and you’ll have a robust Ruby On Rails development environment on your Ubuntu 14.04 system.