博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
如何在Heroku上快速度的创建一个项目
阅读量:7235 次
发布时间:2019-06-29

本文共 1786 字,大约阅读时间需要 5 分钟。

hot3.png

Heroku是用git来管理项目的,另外还要用到ssh来登录,这两个工具请自行安装。

要用Heroku,当然就要安装它了。
$ sudo gem install heroku
先要生成一个公钥,使用命令:
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa):
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
a6:88:0a:bb:74:70:c6:e0:d5:49:65:e3:04:d5:6c:3e 
把公钥加入到Heroku
$ heroku keys:add
Uploading ssh public key /home/user/.ssh/id_rsa.pub
如果想删除公钥,可以用命令:
$ heroku keys:remove 
查看公钥,用命令:
$ heroku keys
现在就可以创建一个项目了(预先要安装好rails)。
$ rails myapp
$ git init
$ git add .
$ git commit -m "my first commit"
Created initial commit 5df2d09: my first commit
44 files changed, 8393 insertions(+), 0 deletions(-)
create mode 100644 README
create mode 100644 Rakefile
create mode 100644 app/controllers/application.rb
...
把这个项目创建到Heroku上。
$ heroku create myapp
Enter your Heroku credentials.
Email: 
Password: 
Uploading ssh public key /home/user/.ssh/id_rsa.pub
(当第一次运行heroku命令时,会创建~/.heroku/credentials文件,这个文件记录了你输入的用户名和密码,这个是在Heroku注册的用户名和密码。)
接下来运行:
$ git push heroku master
Counting objects: 65, done.
Compressing objects: 100% (58/58), done.
Writing objects: 100% (65/65), 80.54 KiB, done.
Total 65 (delta 14), reused 0 (delta 0)
-----> Heroku receiving push
-----> Rails app detected
Compiled slug size is 0.1MB
-----> Launching....... done
App deployed to Heroku
To git@heroku.com:vivid-mountain-91.git
* [new branch] master -> master
再做一个数据库迁移:
$ heroku rake db:migrate
现在就可以像平常使用Rails一样编写程序了。
更新代码可以用:
$ git push herku
将本地数据更新到Heroku网站上:
$ heroku db:push
(这个命令会使用taps,如果没有安装,请先安装。)
要打开网页浏览,就可以用
$ heroku open

转载于:https://my.oschina.net/jeffoscn/blog/263698

你可能感兴趣的文章
Solution: 最近公共祖先·一 [hiho一下 第十三周]
查看>>
Dom4j工具类源码解析
查看>>
rest-framework序列化
查看>>
初学C与C在TC2.0上运行的注意事项
查看>>
CSS-垂直|水平居中问题的解决方法总结
查看>>
Oracle数据库常用命令记录
查看>>
产品开发 - 产品架构
查看>>
一行代码让谷歌浏览器变成在线编辑器
查看>>
Redis的C语言客户端(hiredis)的安装和使用
查看>>
Java 之Object 类
查看>>
Android 调用系统联系人界面的添加联系人,添加已有联系人,编辑和修改。
查看>>
C语言单向链表
查看>>
【LeedCode】3Sum
查看>>
基于Token的WEB后台认证机制
查看>>
hdu1412
查看>>
ssh卡在debug1: SSH2_MSG_KEXINIT sent解决方法
查看>>
HTTP 错误 404.17 - Not Found和 HTTP 错误 404.2 - Not Found 解决办法
查看>>
Python中可迭代对象、迭代器以及iter()函数的两个用法详解
查看>>
C# winform程序防止前台卡死
查看>>
JdbcDaoSupport应用
查看>>