Skip to content

Instantly share code, notes, and snippets.

@tagrudev
Last active October 22, 2015 07:59
Show Gist options
  • Save tagrudev/424ae94243c81acec252 to your computer and use it in GitHub Desktop.
Save tagrudev/424ae94243c81acec252 to your computer and use it in GitHub Desktop.
Install Ruby on Ubuntu
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

Now we are ready to install rbenv. The easiest way to do that is to run these commands, as the user that will be using Ruby:

cd
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile

Note: On Ubuntu Desktop, replace all occurrences .bash_profile in the above code block with .bashrc.

This installs rbenv into your home directory, and sets the appropriate environment variables that will allow rbenv to the active version of Ruby.

Now we're ready to install Ruby.

Install Ruby Before using rbenv, determine which version of Ruby that you want to install. We will install the latest version, Ruby 2.2.3.

As the user that will be using Ruby, install it with these commands:

rbenv install -v 2.2.3
rbenv global 2.2.3

The global sub-command sets the default version of Ruby that all of your shells will use. If you want to install and use a different version, simply run the rbenv commands with a different version number.

Verify that Ruby was installed properly with this command:

ruby -v

It is likely that you will not want Rubygems to generate local documentation for each gem that you install, as this process can be lengthy. To disable this, run this command:

echo "gem: --no-document" > ~/.gemrc

You will also want to install the bundler gem, to manage your application dependencies:

gem install bundler

Now that Ruby is installed, let's install Rails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment