在Amazon Web Service EC2上运行rails server

前提是ruby, rails, bundle等相关已经安装好。或者直接选择的ruby环境的EC2.

取一个git上的例子说明:

1.  git clone git://github.com/saasbook/hw2_rottenpotatoes.git

从Git上下载这个git代码。

2. cd hw2_rottenpotatoes

到当前文件目录

3. bundle install --without production

下载一系列的gem包。--without production part of the command causes the installer to ignore the
PostgreSQL gem for your local installation。(since that gem will cause problems if you're using a
development environment without PostgreSQL installed).
4. 你可以去查看下 db/seeds.rb  里面的代码,就是一些电影相关信息。

5. rake db:migrate     把所有rottenpotatoes移到本地数据库。

6. rake db:seed        to seed your local database with the movies from the seed file.

7. rails server   启动rails server



如果是在本地上跑,或者用VM, 那么只需要打开 localhost:3000/movies  就能看到电影内容了。

问题如果是用的Amazon Web Service, EC2,   还需要在console management的界面左边点 "Security groups", 增加一个"custom TCP" 协议, 端口是3000, source用默认的0.0.0.0/0。  这样就可以开放aws-EC2的3000端口了。  然后用EC2的 public DNS加端口号访问即可。  比如

ec2-183-71-2-31.us-west-1.compute.amazonaws.com:3000


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值