It can be installed using sudo apt-get install ruby, but the version installed in this way is generally older. Alternatively, you can install the new version in the following ways.
1. First update the software source, using the domestic. Reference: Http://wiki.ubuntu.org.cn/%E6%BA%90%E5%88%97%E8%A1%A8
2. Refresh the list:
sudo apt-get update
3. Install the necessary:
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-de
4. Install Ruby using 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
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
rbenv install 2.2.0
rbenv global 2.2.0
ruby -v
5. Or use RVM to install (4 and 52 select one)
\curl-l https://Get.rvm.io | bash-s stablesource ~/install ruby-2.2
.0
rvm listrvm use --default ruby-2.2.0
$HOME/.rvm/rubies export PATH=$PATH:$HOME/.rvm/rubies/ruby-2.2.0/bin
6. Use Taobao's rubygems image
Gem sources--remove https://rubygems.org/gem sources-a https://ruby.taobao.org/
7. If you use bundles, modify the Gemfile
' https://ruby.taobao.org/ '
Linux Install Ruby