登录:
➜ ~ heroku login
先要生成一个公钥,使用命令:
➜ ~ ssh-keygen -t rsa
Generating public/private rsa key pair.
...
把公钥加入到Heroku:
➜ ~ heroku keys:add
Found an SSH public key at /home/user/.ssh/id_rsa.pub
? Would you like to upload it to Heroku? Yes
Uploading /home/user/.ssh/id_rsa.pub SSH key... done
如果想删除公钥,可以用命令:
➜ ~ heroku keys:remove user@workstation.local
查看公钥,用命令:
➜ ~ heroku keys
现在就可以创建一个项目了(预先要安装好rails)。
➜ ~ rails myapp
➜ ~ git init
➜ ~ git add .
➜ ~ git commit -m "my first commit"
Created initial commit 5df2d09: my first commit
...
把这个项目创建到Heroku上。
➜ ~ heroku create myapp
Enter your Heroku credentials.
Email: user@example.com
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
heroku config:
// https://devcenter.heroku.com/articles/config-vars
➜ ~ heroku config -a <app-name>
➜ ~ heroku config:get CONFIG_NAME -a <app-name>
➜ ~ heroku config:set CONFIG_NAME=myconfig -a <app-name>
➜ ~ heroku config:unset CONFIG_NAME -a <app-name>