Ruby安装

1.系统环境

  • Ubuntu      ubuntu-14.04 64位

2.安装CURL

# apt-get install curl

3.安装RVM

在安装 Ruby 之前,先要安装 RVM:
$ curl -sSL https://get.rvm.io | bash -s stable

如果你已经安装了RVM,可以运行下面的命令,确保安装的是最新版本:
$ rvm get stable

运行下面的命令检查安装Ruby的需求条件:

$ rvm requirements
如果提示“command not found”,可以运行下面的命令:
$ source /usr/local/rvm/scripts/rvm

注:因为我的电脑自动安装到此目录,所以用上面的路径,如果你的不是,切换到你的目录即可。

如果是在Centos上可以按下面操作:
* First you need to add all users that will be using rvm to 'rvm' group,
    and logout - login again, anyone using rvm will be operating with `umask u=rwx,g=rwx,o=rx`.


  * To start using RVM you need to run `source /etc/profile.d/rvm.sh`
    in all your open shell windows, in rare cases you need to reopen all shell windows.


检查是否安装成功:
root@ubuntu:~# rvm -v

rvm 1.25.27 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

4.用RVM安装Ruby环境

root@ubuntu:~# rvm install 2.1.0

同前面一样需要等待一段时间,完成以后,Ruby,Ruby Gems就安装好了。

5.安装Rails

$ gem install rails --version 4.1.0 --no-ri --no-rdoc

检查Rails是否安装成功,执行以下命令显示Rails的版本号:
root@ubuntu:~# rails -v  

说明:如果出现ERROR:  Could not find a valid gem 'rails' (= 4.1.0), here is why:
Unable to download data from https://rubygems.org/ - Errno::ECONNREFUSED: Connection refused - connect(2) for "s3.amazonaws.com" port 443 (https://api.rubygems.org/specs.4.8.gz)
解决方案: RubyGems 镜像

6.常用依赖

# apt-get install openssl libmysqlclient15-dev nodejs

7.经常遇到的问题

  • 如果ubuntu自带的终端找不到ruby命令,可以按下面操作:
A RVM version 1.25.28 (stable) is installed yet 1.25.27 (stable) is loaded.
Please do one of the following:
  * 'rvm reload'
  * open a new shell
  * 'echo rvm_auto_reload_flag=1 >> ~/.rvmrc' # for auto reload with msg.
  * 'echo rvm_auto_reload_flag=2 >> ~/.rvmrc' # for silent auto reload.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值