Install Ruby environment in Ubuntu

Hello, dear users. Now we will install ruby environment on our Ubuntu OS.

Install Ruby

  1. Before of all we need prepare our system
sudo apt-get update
sudo apt-get install git-core curl libcurl4-openssl-dev libxslt1-dev zlib1g-dev  build-essential libssl-dev libreadline-dev  sqlite3 libxml2-dev   python-software-properties libsqlite3-dev
  1. Install via rbenv
cd ~/
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL

Currently, we installed tools for using multiple version of ruby. Next step, we will install Ruby.

  1. Install Ruby

It can take some time, you can make tea or take beer (I advise tea :))

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

3.1 Installing Ruby in your system

Drink tea, again ;)

rbenv install 2.2.2
rbenv global 2.2.2

Check installed version:

ruby -v

And finally, we don’t need documentation on our system, we always can find it on github :)

echo "gem: --no-ri --no-rdoc" > ~/.gemrc

The major reason why you need to install ruby is a Ruby On Rails framework.

Install Ruby On Rails

Installing RoR is very simple, only few steps.

  1. Install nodejs
sudo apt-get install nodejs
  1. Install RoR
gem install rails
rbenv rehash
rails -v
  1. Install bundle
gem install bundler

Test, installing RoR:

rails new test_app_name
cd new_app
rails server

After last command we run web server (and have output, like this). Now we can show our app in action, just go to page http://localhost:3000

max~/app$ rails server
=> Booting WEBrick
=> Rails 4.2.4 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2015-12-06 15:17:01] INFO  WEBrick 1.3.1
[2015-12-06 15:17:01] INFO  ruby 2.2.2 (2015-04-13) [x86_64-linux]
[2015-12-06 15:17:01] INFO  WEBrick::HTTPServer#start: pid=2586 port=3000

You must get page like this: Show how worked Ruby on Rails aplication

Install PostgreSQL

sudo apt-get install postgresql libpq-dev
sudo su postgres -c psql
postgres=# CREATE ROLE <user_name> SUPERUSER LOGIN;
postgres=# \q

Bonus

For fast installing all things in “fresh” OS, I recomend this script ubuntu_laptop.sh




Share this article with your friends