部署rails项目到heroku

1.修改数据库

heroku使用的是PostgreSql而不是sqlite3,因此需要修改Gemfile以后才可以到heroku上运行。修改Gemfile中的:

gem 'sqlite3'

将它改为:

group :development do
  gem 'sqlite3'
end
group :production do
  gem 'pg'
end

这样在开发环境中使用Sqlite3,在部署上线后使用PostgreSql.

2.加载库

bundle install --without production

3.登录heroku

heroku login

会提示输入email和password,登录成功后新建app:

heroku create --stack cedar

4.push代码

把代码加入到git版本库:

git init
git add .
git commit -m "make it better"

push到heroku:

git push heroku master

可以看到以下输出:

remote: ###### WARNING:
remote:        No Procfile detected, using the default web server (webrick)
remote:        https://devcenter.heroku.com/articles/ruby-default-web-server
remote: 
remote: 
remote: -----> Discovering process types
remote:        Procfile declares types     -> (none)
remote:        Default types for buildpack -> console, rake, web, worker
remote: 
remote: -----> Compressing... done, 28.5MB
remote: -----> Launching... done, v7
remote:        https://tuishu.herokuapp.com/ deployed to Heroku
remote: 
remote: Verifying deploy.... done.
To https://git.heroku.com/tuishu.git
   2f25861..959154c  master -> master

当看到Verifying deploy…. done.的时候说明push完毕。

5.迁移数据库

heroku run rake db:migrate

6.访问app

heroku open

7.2这个命令

远程连接:

heroku git:remote -a tuishu

远程clone

heroku git:clone -a tuishu
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

esc_ai

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值