about // doc

Install Ruby and Jekyll in Linux with rvm

Last updated in Feb 2015

Ruby Installation

Many Linux distributions provide Ruby packages in repositories, but I still find RVM is the best way of installing Ruby and managing its versions and packages.

In my Ubuntu, first install dependencies (c compiler and curl)

sudo apt-get install gcc make curl

Second, install a few libraries

sudo apt-get install zlib1g-dev libreadline-dev libssl-dev libxml2-dev

Update (Jan 2015): Add its GPG key of RVM as follows:

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

Now install RVM

\curl -sSL https://get.rvm.io | bash -s stable

and add those lines to ‘$HOME/.bashrc’

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"

which initialize RVM environment in each BASH session. And source the ‘.bashrc’ file

. $HOME/.bashrc

Now it is time to install Ruby. But before that, check

rvm requirements

and it gives you all the packages needed for Ruby installation. Install them before proceeding.

At last, install the Ruby. At the time of writing, the newest Ruby stable version is 2.1.2, so type:

rvm install 2.1.2

The latest stable Ruby version can be found here.

Jekyll Installation

Jekyll is a Ruby gem. So it can be installed with gem.

gem install rdoc  # refer to https://github.com/github/pages-gem/issues/9
gem install jekyll

Update (Jun, 2014): Currently Jekyll requires CoffeeScript gem even if it is not used, which further requires JavaScript runtime. It can be installed with therubyracer gem like this

sudo apt-get install g++
gem install therubyracer

Updated: Aug 2016

The new Jekyll simplify the process, and the build can be automated by the Gemfile and bundle. See Github doc here for more information.

To run Jekyll with a public IP, do

bundle exec jekyll serve --host=0.0.0.0

The “–host=0.0.0.0” will bind server to all IP address rather than the localhost by default.

Jekyll tutorials can be found in Jekyll’s website.