利用heroku搭建服务的方法

1. 在heroku网站上注册账号

https://www.heroku.com/

要使用gmail邮箱进行注册

2. 安装heroku CLI

https://devcenter.heroku.com/articles/getting-started-with-python#set-up

3. 用终端登陆heroku

$ heroku login 

输入邮箱和密码


4. 在heroku上创建一个app的仓库

下面的命令都是在git bash中执行

这里会随机生成一个app的名称(floating-sands-17593),后面可以更改app的名称

$ heroku create 
Creating app... done, floating-sands-17593
https://floating-sands-17593.herokuapp.com/ | https://git.heroku.com/floating-sands-17593.git

如果之前有自己在GitHub上有自己的server的仓库,并且想把自己的仓库放到heroku上面运行,那么可以执行下面命令在自己的仓库下,与heroku仓库进行关联,之后git remote -v命令可以看出时关联上两个仓库,heroku和origin仓库:

$ heroku git:remote --app floating-sands-17593
set git remote heroku to https://git.heroku.com/floating-sands-17593.git

$ git remote -v
heroku  https://git.heroku.com/floating-sands-17593.git (fetch)
heroku  https://git.heroku.com/floating-sands-17593.git (push)
origin  [email protected]:xxxxxxx/myserver.git (fetch)
origin  [email protected]:xxxxxxx/myserver.git (push)

之后,当我们提交代码到自己的origin仓库时,可以执行下面的命令,将修改也提交的本地的heroku仓库的master分支:

$ git push origin HEAD:heroku/master
Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/xxxxxxx/myserver
   30b7661..3f8b4e2  HEAD -> heroku/master

再执行下面的命令,将本地heroku仓库mater分支的代码提交到自己远程的heroku仓库master分支 

$ git push heroku master
Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing obje
  • 1
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值