前言
使用RVM来管理Ruby,建议使用同样的 Ubuntu 版本,以免遇到一些版本不同带来的问题。
参考
http://ruby-china.org/wiki/install-rails-on-ubuntu-12-04-server
配置 Ubuntu 系统
如果你是国内服务器,推荐修改网易的源
- 输入
sudo vi /etc/apt/sources.list
将里面的内容替换成:deb http://mirrors.163.com/ubuntu/ precise main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ precise-security main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ precise-updates main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ precise-proposed main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ precise main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ precise-security main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ precise-updates main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ precise-proposed main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse
- 然后更新一下:
sudo apt-get update
-
安装必要的三方库
sudo apt-get install -y wget vim build-essential openssl libreadline6 libreadline6-dev libmysqlclient-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev libxslt-dev libcurl4-openssl-dev autoconf automake libtool imagemagick libmagickwand-dev libpcre3-dev nodejs libpq-dev
安装 Ruby
安装 RVM
$ curl -L https://get.rvm.io | bash -s stable $ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' >>~/.bashrc $ source ~/.bashrc $ rvm -v
安装 Ruby
如果你是国内服务器,推荐将 RVM 的安装源替换成 Taobao 的镜像服务器,这样安装能更快!
sed -i -e 's/ftp.ruby-lang.org/pub/ruby/ruby.taobao.org/mirrors/ruby/g' ~/.rvm/config/db
用 RVM 安装 Ruby:
$ rvm pkg install readline openssl $ rvm install 2.0.0 $ rvm use 2.0.0 --default $ ruby -v ruby 2.0.0p247
国内服务器推荐替换 RubyGems 的到淘宝镜像:
$ gem sources --remove https://rubygems.org/ $ gem sources -a http://ruby.taobao.org/ $ gem sources -l *** CURRENT SOURCES *** http://ruby.taobao.org