1 安装Ruby
下载最新的 Ruby
# tar zxvf ruby-2.0.0-p0.tar.gz
# cd ruby-2.0.0-p0
# ./configure
# make
# make install
# ruby -v
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux]
# tar zxvf ruby-2.0.0-p0.tar.gz# cd ruby-2.0.0-p0# ./configure# make # make install# ruby -vruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux]
2 安装gem
下载最新的gem
# tar zxvf rubygems-1.8.25.tgz
# cd rubygems-1.8.25
# ruby setup.rb
# gem -v
1.8.25
# tar zxvf rubygems-1.8.25.tgz# cd rubygems-1.8.25# ruby setup.rb# gem -v1.8.25
3 安装Rails(由于网络不同可能会慢)
#gem install rails
# rails -v
Rails 3.2.13
#gem install rails# rails -vRails 3.2.13
4 创建第一个程序
# rails new ./hello
# rails new ./hello
5 安装所需组建(个人这样认为)
#cd hello
#bundle install (由于网络不同,可能会很慢)
#cd hello #bundle install (由于网络不同,可能会很慢)
问题:
An error occurred while installing sqlite3 (1.3.7), and Bundler cannot continue.Make sure that `gem install sqlite3 -v '1.3.7'` succeeds before bundling.
解决方法:安装所需程序 yum -y install sqlite* 应该是缺少某些支持,我全装了
6 运行
在hello 目录下 rails s
问题:
/usr/local/lib/ruby/gems/2.0.0/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
解决:
vim Gemfile
文件中添加
gem 'execjs'
gem 'therubyracer'
然后 gem install execjs
gem install therubyracer
再次
bundle install
启动 rails s 成功!
访问 :http://localhost:3000