Install Ruby on rails on Ubuntu 14.04 LST
来源:互联网 发布:电脑淘宝淘口令怎么弄 编辑:程序博客网 时间:2024/05/19 03:45
安装rails历经两天,看了网上许多教程,最后以该博客为准尝试安装终于成功。安装过程中有某些地方不一致,但大体相同。在本文最后部分将会介绍安装过程中遇到的一些问题与解决办法。
安装过程
1. Install Git and Curl
Git:是一个简单,快速,高效的版本控制系统。(对于安装ruby on rails 环境没有关系,只是为了在以后的开发过程中进行版本控制的时候使用。)
Curl:是一个根据web协议获取文件的简单命令行工具。
1 sudo apt-get install git
2 sudo apt-get install curl
2. Install RVM and Dependencies
根据查阅网上资料,安装RVM可以更加方便有效的对ruby进行版本管理等
1 curl -L get.rvm.io | bash -s stable
load the RVM
1 source ~/.rvm/scripts/rvm
然后我们继续安装其他一些额外的依赖软件包,如sqlite3,它是默认的数据库等。
1 sudo apt-get -y install build-essential openssl libreadline6 libreadline6-dev 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
3. Installing Javascript Runtime
1 sudo apt-add-repository ppa:chris-lea/node.js
2 sudo apt-get update
3 sudo apt-get install nodejs
4. Install Ruby
1 rvm install 2.0.0
2 rvm use 2.0.0 –default // 选择你想使用的版本
一般有些人在执行第二个命令是会报错
RVM is not a function, selecting rubies with ‘rvm use …’ will not work.
You need to change your terminal emulator preferences to allow login shell. Sometimes it is required to use/bin/bash --login
as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for a example.
根据问题提示,执行下面的命令解决该问题
1 /bin/bash –login
5. Install Rails
1 gem install rails
6. Check on your version
1 ruby -v
ruby 2.0.0p643 (2015-02-25 revision 49749) [x86_64-linux]
2 rails -v
Rails 4.2.4
7. Test
即使在第六步中你能正常显示安装版本,但是也并不一定代表你成功安装,通过新建一个工程,开启服务来检测是否真正成功。
gozky@gozky-Ideapad-Z460:~/ruby_test$ rails new blog //新建工程
create
create README.rdoc
create Rakefile
create config.ru
…..
create vendor/assets/javascripts/.keep
create vendor/assets/stylesheets
create vendor/assets/stylesheets/.keep
run bundle install
Fetching gem metadata from https://ruby.taobao.org/…………
Fetching version metadata from https://ruby.taobao.org/..
Resolving dependencies……….
Using rack-test 0.6.3
….
接着启动服务,记得要进入你新建的工程文件中
gozky@gozky-Ideapad-Z460:~/ruby_test/blog$ rails server
=> Booting WEBrick
=> Rails 4.2.4 application starting in development on http://localhost:3000
=> Runrails server -h
for more startup options
=> Ctrl-C to shutdown server
[2015-09-25 10:55:44] INFO WEBrick 1.3.1
[2015-09-25 10:55:44] INFO ruby 2.0.0 (2015-02-25) [x86_64-linux]
[2015-09-25 10:55:44] INFO WEBrick::HTTPServer#start: pid=5155 port=3000Started GET “/” for 127.0.0.1 at 2015-09-25 11:00:38 +0800
Processing by Rails::WelcomeController#index as HTML
Rendered /home/gozky/.rvm/gems/ruby-2.0.0-p643/gems/railties-4.2.4/lib/rails/templates/rails/welcome/index.html.erb (1.5ms)
Completed 200 OK in 18ms (Views: 7.7ms | ActiveRecord: 0.0ms)
Q&A
Error1: 出现类似于“Installing ri documentation for rails-3.2.3… file ‘lib’ not found”的错误,执行下面的命令就可以了:
gem install rdoc
Error2: 出现类似某些路径下的文件不被允许写,没有权限,可以在安装命令前加上sudo
Error3: 出现下面错误
Fetching gem metadata from RubyGems.org…….
Fetching version metadata from RubyGems.org…
Fetching dependency metadata from RubyGems.org..
Gem::RemoteFetcher::FetchError: Errno::ETIMEDOUT: Connection timed out - connect(2) (https://rubygems.org/gems/rake-10.1.0.gem)
An error occurred while installing rake (10.1.0), and Bundler cannot continue
是由于被墙的缘故,或者你可以翻墙,或者你也可以修改源地址
gem sources –remove https://rubygems.org/
gem sources -a https://ruby.taobao.org/
如果在new一个新工程还出错,继续尝试下面的命令
bundle config mirror.https://rubygems.org https://ruby.taobao.org
- Install Ruby on rails on Ubuntu 14.04 LST
- 【Ruby on Rails】Install rjb on Ubuntu
- install Ruby on Rails
- Install Ruby on Rails on Ubuntu 12.04 LTS
- Ruby On Rails Ubuntu
- CentOS install Ruby On Rails
- install ruby on rails debian
- Install ruby on rails on CentOS
- How to install Ruby on Rails in Ubuntu 11.10
- ruby on rails - ubuntu篇
- Ubuntu 配置Ruby on Rails
- Ubuntu 安装ruby on rails
- Ruby on rails连接Mysql (on ubuntu)
- ruby on rails install Records @Linux
- ruby on rails: bundle install 耗时太长
- How to Install Ruby on Rails on Ubuntu 12.04 LTS (Precise Pangolin) with RVM
- ubuntu 14.04中安装ruby on rails环境(填坑版)
- ubuntu 14.04中安装 ruby on rails 环境(填坑)
- 利用Echarts来制作图表
- Intellij Idea中运行tomcat 报內存溢出 解决方案
- Errors running builder 'DeploymentBuilder' on project
- 深度学习之卷积神经网络
- jieba(结巴)Python分词器加载到Eclipse方法
- Install Ruby on rails on Ubuntu 14.04 LST
- 安卓APK反编译与混淆编译
- 排序算法四:交换排序之冒泡排序
- jQuery EasyUI动态添加控件或者ajax加载页面后不能自动渲染问题的解决方法
- 梯度下降法学习速率设置技巧
- mysql触发器实践
- OCS为什么不能安装到除C盘以外的盘
- OCS部署后不能返回信息的问题解决…
- MJRefresh的下拉刷新及上拉加载(施工中)