1.操作系统 centos5.4

2.安装ruby

yum install ruby

会安装得到 1.8.5

如果你公司用的是1.8.X就无所谓了,

拿这个学习就行了

如果你们公司用的是1.9.X,那么你需要去下载源码进行安装。【你会很悲剧的发现下载已被伟大祖国的万里长城封锁了】

我这里使用1.8.5学习就ok了

3.安装rails

yum -y install rubygem-rails.noarch

4.看看安装完毕的成果

[root@localhost projects]# ruby -v

ruby 1.8.5 (2006-08-25) [x86_64-linux]

[root@localhost projects]# rails -v

Rails 2.1.1

5.建立rails档案

mkdir projects

cd projects

rails new demo 

圣经说:

如果出現建立出來的目錄不是demo而是new,表示你的Rails版本是舊版的,請輸入rails -v檢查Rails的版本必須是3.0以上。不是的話,請回上一章末執行gem install rails安裝Rails 3

 老版本就老版本吧

不管他

6.启动服务器 ./script/server 

[root@localhost new]# ./script/server 

=> Booting WEBrick...

=> Rails 2.1.1 application started on http://0.0.0.0:3000

=> Ctrl-C to shutdown server; call with --help for options

[2013-07-16 09:29:45] INFO  WEBrick 1.3.1

[2013-07-16 09:29:45] INFO  ruby 1.8.5 (2006-08-25) [x86_64-linux]

[2013-07-16 09:29:45] INFO  WEBrick::HTTPServer#start: pid=17229 port=3000

8.访问一下

本地访问:

[root@localhost ~]# curl "127.0.0.1:3000"

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

  <head>

    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />

    <title>Ruby on Rails: Welcome aboard</title>

    <style type="text/css" media="screen">

      body {

        margin: 0;

        margin-bottom: 25px;

        padding: 0;

        background-color: #f0f0f0;

        font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana";

        font-size: 13px;

        color: #333;

      }

      

      h1 {

        font-size: 28px;

        color: #000;

      }

      

      a  {color: #03c}

      a:hover {

        background-color: #03c;

        color: white;

        text-decoration: none;

      }

      

      

      #page {

        background-color: #f0f0f0;

        width: 750px;

        margin: 0;

        margin-left: auto;

        margin-right: auto;

      }

      

      #content {

        float: left;

        background-color: white;

        border: 3px solid #aaa;

        border-top: none;

        padding: 25px;

        width: 500px;

      }

      

      #sidebar {

        float: right;

        width: 175px;

      }

 

      #footer {

        clear: both;

      }

      

 

      #header, #about, #getting-started {

        padding-left: 75px;

        padding-right: 30px;

      }

 

 

      #header {

        background-image: url("images/rails.png");

        background-repeat: no-repeat;

        background-position: top left;

        height: 64px;

      }

      #header h1, #header h2 {margin: 0}

      #header h2 {

        color: #888;

        font-weight: normal;

        font-size: 16px;

      }

      

      

      #about h3 {

        margin: 0;

        margin-bottom: 10px;

        font-size: 14px;

      }

      

      #about-content {

        background-color: #ffd;

        border: 1px solid #fc0;

        margin-left: -11px;

      }

      #about-content table {

        margin-top: 10px;

        margin-bottom: 10px;

        font-size: 11px;

        border-collapse: collapse;

      }

      #about-content td {

        padding: 10px;

        padding-top: 3px;

        padding-bottom: 3px;

      }

      #about-content td.name  {color: #555}

      #about-content td.value {color: #000}

      

      #about-content.failure {

        background-color: #fcc;

        border: 1px solid #f00;

      }

      #about-content.failure p {

        margin: 0;

        padding: 10px;

      }

      

      

      #getting-started {

        border-top: 1px solid #ccc;

        margin-top: 25px;

        padding-top: 15px;

      }

      #getting-started h1 {

        margin: 0;

        font-size: 20px;

      }

      #getting-started h2 {

        margin: 0;

        font-size: 14px;

        font-weight: normal;

        color: #333;

        margin-bottom: 25px;

      }

      #getting-started ol {

        margin-left: 0;

        padding-left: 0;

      }

      #getting-started li {

        font-size: 18px;

        color: #888;

        margin-bottom: 25px;

      }

      #getting-started li h2 {

        margin: 0;

        font-weight: normal;

        font-size: 18px;

        color: #333;

      }

      #getting-started li p {

        color: #555;

        font-size: 13px;

      }

      

      

      #search {

        margin: 0;

        padding-top: 10px;

        padding-bottom: 10px;

        font-size: 11px;

      }

      #search input {

        font-size: 11px;

        margin: 2px;

      }

      #search-text {width: 170px}

      

      

      #sidebar ul {

        margin-left: 0;

        padding-left: 0;

      }

      #sidebar ul h3 {

        margin-top: 25px;

        font-size: 16px;

        padding-bottom: 10px;

        border-bottom: 1px solid #ccc;

      }

      #sidebar li {

        list-style-type: none;

      }

      #sidebar ul.links li {

        margin-bottom: 5px;

      }

      

    </style>

    <script type="text/javascript" src="javascripts/prototype.js"></script>

    <script type="text/javascript" src="javascripts/effects.js"></script>

    <script type="text/javascript">

      function about() {

        if (Element.empty('about-content')) {

          new Ajax.Updater('about-content', 'rails/info/properties', {

            method:     'get',

            onFailure:  function() {Element.classNames('about-content').add('failure')},

            onComplete: function() {new Effect.BlindDown('about-content', {duration: 0.25})}

          });

        } else {

          new Effect[Element.visible('about-content') ? 

            'BlindUp' : 'BlindDown']('about-content', {duration: 0.25});

        }

      }

      

      window.onload = function() {

        $('search-text').value = '';

        $('search').onsubmit = function() {

          $('search-text').value = 'site:rubyonrails.org ' + $F('search-text');

        }

      }

    </script>

  </head>

  <body>

    <div id="page">

      <div id="sidebar">

        <ul id="sidebar-items">

          <li>

            <form id="search" action="http://www.google.com/search" method="get">

              <input type="hidden" name="hl" value="en" />

              <input type="text" id="search-text" name="q" value="site:rubyonrails.org " />

              <input type="submit" value="Search" /> the Rails site

            </form>

          </li>

        

          <li>

            <h3>Join the community</h3>

            <ul class="links">

              <li><a href="http://www.rubyonrails.org/">Ruby on Rails</a></li>

              <li><a href="http://weblog.rubyonrails.org/">Official weblog</a></li>

              <li><a href="http://wiki.rubyonrails.org/">Wiki</a></li>

            </ul>

          </li>

          

          <li>

            <h3>Browse the documentation</h3>

            <ul class="links">

              <li><a href="http://api.rubyonrails.org/">Rails API</a></li>

              <li><a href="http://stdlib.rubyonrails.org/">Ruby standard library</a></li>

              <li><a href="http://corelib.rubyonrails.org/">Ruby core</a></li>

            </ul>

          </li>

        </ul>

      </div>

 

      <div id="content">

        <div id="header">

          <h1>Welcome aboard</h1>

          <h2>You&rsquo;re riding Ruby on Rails!</h2>

        </div>

 

        <div id="about">

          <h3><a href="rails/info/properties" onclick="about(); return false">About your application&rsquo;s environment</a></h3>

          <div id="about-content" style="display: none"></div>

        </div>

        

        <div id="getting-started">

          <h1>Getting started</h1>

          <h2>Here&rsquo;s how to get rolling:</h2>

          

          <ol>          

            <li>

              <h2>Use <tt>script/generate</tt> to create your models and controllers</h2>

              <p>To see all available options, run it without parameters.</p>

            </li>

            

            <li>

              <h2>Set up a default route and remove or rename this file</h2>

              <p>Routes are set up in config/routes.rb.</p>

            </li>

 

            <li>

              <h2>Create your database</h2>

              <p>Run <tt>rake db:migrate</tt> to create your database. If you're not using SQLite (the default), edit <tt>config/database.yml</tt> with your username and password.</p>

            </li>

          </ol>

        </div>

      </div>

      

      <div id="footer">&nbsp;</div>

    </div>

  </body>

</html>

远程访问:有问题


判断是iptables造成

</html>[root@localhost ~]# iptables -L

Chain INPUT (policy ACCEPT)

target     prot opt source               destination         

RH-Firewall-1-INPUT  all  --  anywhere             anywhere            

 

Chain FORWARD (policy ACCEPT)

target     prot opt source               destination         

RH-Firewall-1-INPUT  all  --  anywhere             anywhere            

 

Chain OUTPUT (policy ACCEPT)

target     prot opt source               destination         

 

Chain RH-Firewall-1-INPUT (2 references)

target     prot opt source               destination         

ACCEPT     all  --  anywhere             anywhere            

ACCEPT     icmp --  anywhere             anywhere            icmp any 

ACCEPT     esp  --  anywhere             anywhere            

ACCEPT     ah   --  anywhere             anywhere            

ACCEPT     udp  --  anywhere             224.0.0.251         udp dpt:mdns 

ACCEPT     udp  --  anywhere             anywhere            udp dpt:ipp 

ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ipp 

ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 

ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh 

ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:https 

ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:http 

REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited 

关闭防火墙

iptables -F

再次访问没问题了

Ruby on Rails 實戰聖經阅读(二)的更多相关文章

  1. Ruby on Rails 實戰聖經阅读(三)

    由于是1.8.x:圣经的1.9.3差太多,所以另外按1.8.X来创建hello world 第一個Hello World!! 1. 创建项目rails -d mysql first 2.创建控制器  ...

  2. 如何从 0 开始学 ruby on rails (漫步版)

    如何从 0 开始学 ruby on rails (漫步版) ruby 是一门编程语言,ruby on rails 是 ruby 的一个 web 框架,简称 rails. 有很多人对  rails 感兴 ...

  3. 如何从 0 开始学 Ruby on Rails

    如何从 0 开始学 Ruby on Rails (漫步版)Ruby 是一门编程语言,Ruby on Rails 是 Ruby 的一个 web 框架,简称 Rails. 有很多人对 Rails 感兴趣, ...

  4. (转) 如何从 0 开始学 ruby on rails (漫步版)

    原文:http://readful.com/post/12322300571/0-ruby-on-rails ruby 是一门编程语言,ruby on rails 是 ruby 的一个 web 框架, ...

  5. 《Ruby on Rails教程》学习笔记

    本文是我在阅读 Ruby on Rails 教程的简体中文版时所做的摘录,以及学习时寻找的补充知识.补充知识主要来自于 Ruby on Rails 實戰聖經. Asset Pipeline 在最新版 ...

  6. [转]2010 Ruby on Rails 書單 與 練習作業

    原帖:http://wp.xdite.net/?p=1754 ========= 學習 Ruby on Rails 最快的途徑無非是直接使用 Rails 撰寫產品.而這個過程中若有 mentor 指導 ...

  7. ruby on rails on windows

    这次想系统学会rails,最终目标是将redmine改造成顺手的工具,主要的手段就是开发redmine插件.虽然网上都推荐使用类Unix系统,可手头只有win7系统,就安装了. 难免会遇到这样那样的问 ...

  8. 10个基于 Ruby on Rails 构建的顶级站点

    本文系国内 ITOM 行业领军企业 OneAPM 工程师翻译整理自 Raviraj Hegde 的文章 Top Sites Built with Ruby on Rails. 就其本身而言,Ruby ...

  9. Ruby on Rails创始人DHH谈如何进行混合移动APP开发

    混合型APP兼具原生型APP软件良好用户交互体验的优势和网页型APP软件跨平台开发的优势,并且其开发成本和网页型APP软件接近,其开发效率也远高于原生型APP软件.混合型APP已经被众多企业所认可.最 ...

随机推荐

  1. Cannot drop the database ‘XXX’ because it is being used for replication.

    删除订阅数据库的时候出现下面的错误: Cannot drop the database ‘XXX’  because it is being used for replication. 数据库的状态为 ...

  2. [转]tripwire-文件指纹

    原文链接:http://www.ipython.me/centos/tripwire-file-md5.html Tripwire是目前最为著名的unix下文件系统完整性检查的软件工具,这一软件采用的 ...

  3. 演练5-4:Contoso大学校园管理系统4

    在之前的教程中,我们已经完成了学校的数据模型.现在我们将读取和显示相关数据,请理解EF加载导航属性的方式. 一.Lazy.Eager.Explicit数据加载 使用EF为实体中的导航属性加载相关数据, ...

  4. Qt同步线程(比较清楚,而且QMutex QMutexLocker QReadWriteLock QSemaphore QWaitCondition 每个都有例子)

    Qt同步线程 我们知道,多线程有的时候是很有用的,但是在访问一些公共的资源或者数据时,需要进行同步,否则会使数据遭到破坏或者获取的值不正确.Qt提供了一些类来实现线程的同步,如QMutex,QMute ...

  5. AES加密时抛出java.security.InvalidKeyException: Illegal key size or def

    原文:AES加密时抛出java.security.InvalidKeyException: Illegal key size or def 使用AES加密时,当密钥大于128时,代码会抛出 java. ...

  6. mysql数据库修改数据库编码,字段编码与表编码(转) good

    最近看了一下KIGG框架,发现在用EF + MYSQL数据库时,数据出现了乱码,用工具(Navicat )查看一下表category的结构发现 KIGG 数据库的默认情况是用latin1编码的(DEF ...

  7. (读书笔记).NET大局观-.NET框架类库概观

    .NET框架类库概况 构建在.NET框架上所有的软件,都会用到通用语言进行时,即使基于最简单的CLR程序,也需要用到一部分.NET框架类库,更精致复杂的软件则使用这个类库提供的更多服务. .NET框架 ...

  8. NOI08冬令营 数据结构的提炼与压缩

    无聊随手翻,翻到了一个这样的好东西--据结构的提炼与压缩: 为了防止以后忘记,这里把论文里的题目都纪录一下吧. 1.二维结构的化简 问题一:ural 1568 Train car sorting 定义 ...

  9. spoj 1812 lcsII (后缀自动机)

    spoj 1812 lcsII (后缀自动机) 题意:求多个串的lcs,最多10个串,每个串最长10w 解题思路:后缀自动机.先建好第一个串的sam,然后后面的串拿上去跑(这个过程同前一题).sam上 ...

  10. opencv视频播放

    在一个界面上显示一张图片.是一件非常easy的事情,但说到要显示视频.刚開始学习的人可能不知道怎么处理,事实上,一般来说能够理解为视频就是图片以人眼察觉不到的速度高速更新. 曾经用摄像头採集视频显示在 ...