安装ruby

# Ubuntu系统下安装ruby/rails必要的库和编译环境
sudo apt-get update
sudo apt-get install -y build-essential openssl curl libcurl3-dev libreadline6 libreadline6-dev git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev libxslt-dev autoconf automake libtool imagemagick libmagickwand-dev libpcre3-dev libsqlite3-dev
# rbenv环境安装
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(rbenv init - zsh)"' >> ~/.zshrc
source ~/.zshrc
type rbenv
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
# ruby环境安装,首先列出可安装的版本,然后选择后进行下载编译
rbenv install -l
rbenv install 2.2.3
# 设置当前使用的ruby版本并将gem的源改为淘宝镜像
rbenv global 2.2.3
rbenv rehash
gem sources --remove https://rubygems.org/
gem sources -a http://ruby.taobao.org/
# 安装rails
gem install bundler rails --no-rdoc --no-ri
# 检查安装后的软件版本
ruby -v
gem -v
rake -V
rails -v

发表评论