本教程只适合 Ubuntu Server 用于部署项目到线上,建议使用同样的 Ubuntu 版本,以免遇到一些版本不同带来的问题。
本教程适合新手初次部署 Rails 应用;
Ubuntu 12.04 Server,
服务器安装测试于 Linode VPS (Ubuntu 12.04 LTS (GNU/Linux 3.4.2-x86_64-linode25 x86_64)。
输入 sudo vi /etc/apt/sources.list 将里面的内容替换成:
deb http://mirrors.163.com/ubuntu/ precise main restricted universe multiversedeb
http://mirrors.163.com/ubuntu/ precise-security main restricted universe multiversedeb
http://mirrors.163.com/ubuntu/ precise-updates main restricted universe multiversedeb
http://mirrors.163.com/ubuntu/ precise-proposed main restricted universe multiversedeb
http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiversedeb-src
http://mirrors.163.com/ubuntu/ precise main restricted universe multiversedeb-src
http://mirrors.163.com/ubuntu/ precise-security main restricted universe multiversedeb-src
http://mirrors.163.com/ubuntu/ precise-updates main restricted universe multiversedeb-src
http://mirrors.163.com/ubuntu/ precise-proposed main restricted universe multiversedeb-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
$ /curl -L https://get.rvm.io | bash -s stable $ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' >>~/.bashrc $ source ~/.bashrc $ rvm -v
如果你是国内服务器,推荐将 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 -vruby 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
$ gem install rails $ rails -vRails 4.0.0
新闻热点
疑难解答