Dev Notes

Various Cheat Sheets and Resources by David Egan/Carawebs.

Install Ruby & Ruby on Rails in Ubuntu Xenial

David Egan

This guide involves:

  • Setting up Ruby using rbenv
  • Installing Node
  • Installing Rails

Install Ruby Dependencies

Packages required to build ruby.

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 rbenv & ruby-build

git clone ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc

# Add command completion scripts into path
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL

git clone ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL

rbenv install 2.3.1
rbenv global 2.3.1
ruby -v

Install Bundler

gem install bundler
rbenv rehash

Set Up Git Globally

If you haven’t already done it…

git config --global color.ui true
git config --global "David Egan"
git config --global ""
ssh-keygen -t rsa -b 4096 -C " on xenial-ghost"
cat ~/.ssh/

Copy and paste the contents of the public key to Github/BitBucket.

Check the ssh connection:

ssh -T

Set Up Node

Install Node using NVM (Node Version Manager)


sudo apt-get update
sudo apt-get install build-essential libssl-dev curl
curl -o- | bash
source ~/.profile
nvm ls-remote
nvm install v6.2.2
node -v

Build a quick hello world node app to check:

nano hello.js

# Enter:
console.log(c +' plus '+d+' equals:' +e);
console.log('Hello World! '+a+' '+b);

Run node hello.js in the terminal to output:

2 plus 2 equals:4
Hello World! Nice One!

Install Rails

gem install rails -v 4.2.6
rbenv rehash
rails -v

Build a New Rails App using MySQL(MariaDB)

Assuming that a MySQL server is already installed on the system, prepare Rails for MySQL:

# Requirement to compile the mysql2 gem
sudo apt-get install libmysqlclient-dev

# Gem used by Rails to connect to MySQL
gem install mysql2

Set up new Rails app:

rails new railsapp -d mysql
cd railsapp
rake db:create
rails server


comments powered by Disqus