1 安装Ruby

http://www.ruby-lang.org/en/downloads/ 下载最新的 Ruby

Shell代码 复制代码 收藏代码spinner.gif
  1. # tar zxvf ruby-2.0.0-p0.tar.gz  

  2. # cd ruby-2.0.0-p0  

  3. # ./configure  

  4. # make    

  5. # make install  

  6. # ruby -v  

  7. 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 -v
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux]

2 安装gem

http://rubyforge.org/frs/?group_id=126 下载最新的gem

Shell代码 复制代码 收藏代码spinner.gif
  1. # tar zxvf rubygems-1.8.25.tgz  

  2. # cd rubygems-1.8.25

  3. # ruby setup.rb  

  4. # gem -v  

  5. 1.8.25

# tar zxvf rubygems-1.8.25.tgz
# cd rubygems-1.8.25
# ruby setup.rb
# gem -v
1.8.25

3 安装Rails(由于网络不同可能会慢)


Shell代码 复制代码 收藏代码spinner.gif
  1. #gem install rails  

  2. # rails -v  

  3. Rails 3.2.13

#gem install rails
# rails -v
Rails 3.2.13


4 创建第一个程序

Shell代码 复制代码 收藏代码spinner.gif
  1. # rails new ./hello  

# rails new ./hello

5 安装所需组建(个人这样认为)

Shell代码 复制代码 收藏代码spinner.gif
  1. #cd hello    

  2. #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

文件中添加

  1. gem 'execjs'  

  2. gem 'therubyracer'

然后  gem install execjs  

         gem install therubyracer

再次

        bundle install

启动 rails s 成功!


访问 :http://localhost:3000