首页 技术 正文
技术 2022年11月6日
0 收藏 571 点赞 1,020 浏览 4016 个字

ruby on rails 在fedora18下的安装

天朝的网络原因,安装不是很顺畅,所以把过程记录下备用

前面下载rubygem什么的都比较快,新建一个project的时候会出问题

gem new my_project

会在bundle_install处卡很久,然后提示说某某东西没装,让装一下。。

大体上参考了两篇文章:

【第一篇帖子,google快照里找到的】
在Fedora系统安装Ruby on Rails
这几年一直在用AS3.0做开发,已经很久没有接触Linux了。博客上挂着Fedora的倒计时牌子,每次看到新版本倒计时一个接一个地陆续发布,这个周末重新装上了Fedora,学习一些其他的Web开发知识。虽说Ruby on Rails这几年不是很流行了,而且近期Twitter改用java引起了不小的震动,有些人认为RoR过时了,Ruby日薄西山了。我倒是觉得技术人员与其关注这些,不如去专注学习技术。

RubyonRailsRubyonRails

安装步骤

Fedora更新非常快,我用的是目前最新的Fedora 18。虽然按照文档和教程一步一步安装的,但还是遇到了很多问题。安装的方法有很多种,这个和Ruby语言的特性也很相似 ;-);-) 。考虑到环境配置和开发工作,使用RVM安装比较好,RVM可以管理多个Ruby版本和RubyGem,在开发时可以根据需要切换版本,配置环境也很方便。使用yum安装ruby,管理比较麻烦,不适合开发工作。

安装git和cURL

可以考虑先更新所有包

Bash
yum update
安装git

Bash
yum install git-core
安装curl

Bash
yum install curl
安装RVM

RVM,即Ruby Version Manager,可以管理多个版本Ruby,RubyGem,Rails,对开发来说非常有用。

Bash
curl -L get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm

安装完毕后检查RVM的软件包依赖

Bash
rvm requirements
输出信息如下:

TXT
Requirements for redhat/18./i386

NOTE: ‘ruby’ represents Matz’s Ruby Interpreter (MRI) (1.8.X, 1.9.X)
This is the *original* / standard Ruby Language Interpreter
‘ree’ represents Ruby Enterprise Edition
‘rbx’ represents Rubinius

Additional Dependencies:
# For update-system:

# For rvm:
sudo yum install bash curl git patch

# For ruby:
sudo yum install gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel

# For jruby:
sudo yum install java
安装其它组件

这些软件是在运行时可能要用到的,根据需要安装。

Javascript运行时

访问ExecJS安装可支持的JavaScript运行时,推荐安装Node.js。
这里有点麻烦,可以先尝试通过yum查找,名称不一定是nodejs,如果有就安装

Bash
yum search *nodejs*
yum install nodejs
如果没有,就去找合适的RPM包,或者直接下载源代码编译安装;
安装node.js

Bash
cd node
sudo ./configure
sudo make
sudo make install
喝杯茶等待安装完毕,检查版本

TXT
[anthony@localhost ~]$ node -v
v0.9.8-pre
SQLite等组件

Bash
yum install libxslt-devel libxml2-devel sqlite-devel
安装Ruby

安装了RVM之后,所有Ruby相关的都可以用它来安装配置了。
安装Ruby

Bash
rvm install 1.9.3
如果报错,需要添加参数

Bash
rvm install 1.9.3 –with-openssl-dir=$HOME/.rvm/
使用ruby 1.9.3作为默认版本

Bash
rvm use 1.9.3 –default
检查ruby版本

Bash
ruby -v
更新gems

Bash
gem update
安装Rails

安装rails

Bash
gem install rails
检查rails版本

Bash
rails -v
Rails测试

安装完了,接下来可以用rails生成个helloWorld了。

Bash
mkdir rails_projects
cd rails_projects
rails new first_app
开始创建,喝杯茶……

TXT
create
create README.rdoc
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/assets/images/rails.png
create app/assets/javascripts/application.js
create app/assets/stylesheets/application.css
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create app/views/layouts/application.html.erb
create app/mailers/.gitkeep
create app/models/.gitkeep
create config
create config/routes.rb
create config/application.rb
create config/environment.rb
create config/environments
.
.
.
create vendor/plugins
create vendor/plugins/.gitkeep
run bundle install
Fetching gem metadata from https://rubygems.org/………..
Fetching gem metadata from https://rubygems.org/..
Using rake (10.0.3)
Using i18n (0.6.1)
Using multi_json (1.5.0)
Using activesupport (3.2.11)
Using builder (3.0.4)
Using activemodel (3.2.11)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.4)
Using rails (3.2.11)
Using sass (3.2.5)
Using sass-rails (3.2.6)
Using sqlite3 (1.3.7)
Using uglifier (1.3.0)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
创建完毕,启动服务器

Bash
cd first_app
rails server
好了,打开浏览器,登录 http://localhost:3000看看 :-):-)

总结

万事开头难,第一次安装时经常遇到各种问题:ruby安装失败,gem update报错,rails生成报错,启动报错等等。不过总算完成了,接下来的时间里就要去边做边学了。

另外,我也开始尝试使用Markdown来写文档了,这篇总结就是由Markdown格式转换的。喝水不忘挖井人,最后缅怀一下Aaron Swartz。

Aaron SwartzAaron Swartz

参考资料

http://ruby.railstutorial.org/ruby-on-rails-tutorial-book
http://blog.sudobits.com/2012/05/02/how-to-install-ruby-on-rails-in-ubuntu-12-04-lts/
http://www.evansdiy.com/tips/the+way+to+install+nodejs
https://github.com/joyent/node#readme

【其他文章】
http://stackoverflow.com/questions/9336596/rvm-installation-not-working-rvm-is-not-a-function
stackoverflow上关于rvm文件要生效后才能使用的讨论

http://guides.ruby-china.org/getting_started.html
中文手册,开始按照这个安装步骤做,bundle install处发现了另一个:http://ruby.taobao.org/ 淘宝镜像。。。

json -v 1.8.0https://github.com/wpscanteam/wpscan/issues/92

至于ruby迷说的rails新建工程时的提速问题,可以看http://rubyer.me/blog/941/

为什么要搞ruby on rails?因为看了这里:http://blog.jobbole.com/15213/
关于web的几个方面:框架+部署+版本控制+web语言,框架选择了ruby on rails

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,088
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,564
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,413
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,186
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,822
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,905