Rails安装记录

2016-06-09  本文已影响83人  郝翔

Git

sudo apt-get update
sudo apt-get install git

简单的配置git信息

git config --global user.name "getcha22"
git config --global user.email "getcha576503369@gmail.com"

核查一下输入是否有误

git config --list

剩余的操作参考了github的帮助页面https://help.github.com/articles/generating-ssh-keys/1323

RVM

rails需要先安装Ruby环境,RVM 是 Ruby 管理工具,可以方便的安装、管理、切换多个 Ruby,管理 Gemset。

curl -sSL https://get.rvm.io | bash -s stable

此时会有如下提示信息

getcha22@ubuntu:~/Desktop$ curl -sSL https://get.rvm.io | bash -s stable
Downloading https://github.com/rvm/rvm/archive/1.26.11.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.26.11/1.26.11.tar.gz.asc
gpg: Signature made Mon 30 Mar 2015 02:52:13 PM PDT using RSA key ID BF04FF17
gpg: Can't check signature: public key not found
Warning, RVM 1.26.0 introduces signed releases and automated check of signatures when GPG software found.
Assuming you trust Michal Papis import the mpapis public key (downloading the signatures).

GPG signature verification failed for '/home/getcha22/.rvm/archives/rvm-1.26.11.tgz' - 'https://github.com/rvm/rvm/releases/download/1.26.11/1.26.11.tar.gz.asc'!
try downloading the signatures:

    gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

or if it fails:

    command curl -sSL https://rvm.io/mpapis.asc | gpg --import -

the key can be compared with:
    https://rvm.io/mpapis.asc
    https://keybase.io/mpapis

此时会有如下提示信息

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0

依然会有报错,继续按照提示操作

sudo curl -sSL https://rvm.io/mpapis.asc | gpg --import -

提示Thank you for using RVM!,OK,安装成功

Ruby

Ruby 重启终端,开始安装Ruby,先使用rvm list known来查看可以按照的Ruby列表,按照参考的教程,我选择使用2.2.0

rvm install 2.2.0123

在我安装的过程中,由于vpn不算稳定,出现了404的提示,我尝试重新安装,这次安装成功。 通过下面的命令检查当前的版本:

rvm list

提示结果:


rvm rubies

   ruby-2.2.0 [ x86_64 ]

再进一步核实ruby 的版本, 此时由于ubuntu存在其他版本的ruby,需要制定默认的ruby版本,此时可以使用

rvm --default use 2.2.0

发现有错误提示RVM is not a function,为了解决这个问题,这个问题是由于ubuntu系统的终端导致 ,为了解决这个问题,需要'Run command as login shell,参考这个链接进行解决:https://rvm.io/integration/gnome-terminal 之后重新制定默认版本,提示OK(如果此时已经选中需要勾选的选项,但是依然不行使用bash --login,之后重新rvm use 2.0.0):

ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]

到此为止,ruby的安装告一段落,开始进行rails的安装

rvm gemset create rails4.2
rvm use 2.2.0@rails4.2 --default

gem install rails -v 4.2.0 --no-ri --no-rdoc

先设置Gemset。Gemset 是一个独立的 Gem 集合,可以为每个项目设置自己的 Gemset,而不会相互干扰 出现如下问题

ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    Errno::ECONNRESET: Connection reset by peer - connect(2) for "rubygems.global.ssl.fastly.net" port 443 (https://api.rubygems.org/quick/Marshal.4.8/rails-4.2.4.gemspec.rz)

遇到这个问题,还提示端口是443.可能是gem源导致的网络问题,尝试修改https为http。通过以下命令:

gem sources
gem sources -a url //添加
gem sources -r url  //删除
更新source cache
gem sources -u
// other :
gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/
gem sources -l

之后重新进行安装,结束安装

Successfully installed rails-4.2.0
30 gems installed

此时rails的安装结束了。我们来开始尝试使用

其他情况:
bundle install如果遇到问题,可以先把gemfile中的source修改成http开头即可
如果在操作时提示javascript运行时,只要按照nodejs即可

sudo apt-get install nodejs
上一篇 下一篇

猜你喜欢

热点阅读