http://grandsea.iteye.com/blog/1346613
安装RVM(Ruby Version Manager)
参考 https://rvm.beginrescueend.com/rvm/install/
sudo apt-get install curl
我选择了单用户模式,后面的所有bash命令都是在当前用户模式下执行,没有使用sudo
1、安装最新的稳定版本
- bash -s -- --trace < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
bash -s -- --trace < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
2、将rvm作为function加入shell中(login shell 和 non-login shell),这个会将rvm管理的命令加入到shell中:
- echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
- echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bashrc
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bashrc
3、如果没有重新登录,重新加载shell配置
- source .bash_profile
source .bash_profile
4.、安装缺失的依赖
rvm requirements #查看需要安装那些依赖
5、验证和试用rvm
- rvm -v
- rvm list known
rvm -v
rvm list known
安装Ruby1.9.3
- rvm install 1.9.3
- rvm use 1.9.3 --default #默认使用1.9.3版本,不运行的话,命令行不能找到ruby
rvm install 1.9.3
rvm use 1.9.3 --default #默认使用1.9.3版本,不运行的话,命令行不能找到ruby
使用gem的淘宝镜像
以下引用自http://ruby.taobao.org/
如何使用?
- gem sources --remove http://rubygems.org
- gem sources -a http://ruby.taobao.org/
- gem sources -l
- *** CURRENT SOURCES ***
- http://ruby.taobao.org
- # 请确保只有 ruby.taobao.org
- gem install rails
gem sources --remove http://rubygems.org
gem sources -a http://ruby.taobao.org/
gem sources -l
*** CURRENT SOURCES ***
http://ruby.taobao.org
# 请确保只有 ruby.taobao.org
gem install rails
如果你是用 Bundler (Rails 项目)
修改你的 Gemfile 将
http://rubygems.org
改为
http://ruby.taobao.org/
- source 'http://ruby.taobao.org/'
- gem 'rails', '3.1.1'
- ...
source 'http://ruby.taobao.org/'
gem 'rails', '3.1.1'
...
安装rails
参考http://rubyonrails.org/download
- gem install rails
- rails new path/to/your/new/application
- cd path/to/your/new/application
- rails server
gem install rails
rails new path/to/your/new/application
cd path/to/your/new/application
rails server
可能遇到的异常
rails安装和启动需要gem使用淘宝镜像,还需要修改生成的应用程序的Gemfile文件,具体参加上面。
JavaScript Runtime错误
参考https://github.com/sstephenson/execjs和http://wuhuizhong.iteye.com/blog/1106968需要运行
- gem install therubyracer
gem install therubyracer
然后在gemfile中加入
- gem 'therubyracer'
gem 'therubyracer'
- sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
- bash -s -- --trace < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
- echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
- echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bashrc
- source .bash_profile
- rvm install 1.9.2
- rvm use 1.9.2 --default
- gem sources --remove http://rubygems.org/
- gem sources -a http://ruby.taobao.org/
- gem install rails
- gem install therubyracer