Deploy » 履歴 » バージョン 6
Yuumi Yoshida, 2015-05-26 14:01
| 1 | 5 | Yuumi Yoshida | h1. ヒント と Deploy手順 |
|---|---|---|---|
| 2 | 1 | Yuumi Yoshida | |
| 3 | |||
| 4 | 3 | Yuumi Yoshida | このページのURL http://goo.gl/S0mYkB |
| 5 | 1 | Yuumi Yoshida | |
| 6 | 4 | Yuumi Yoshida | |
| 7 | h2. ヒント |
||
| 8 | |||
| 9 | 6 | Yuumi Yoshida | ファイルに小遣いのデータを書く |
| 10 | 4 | Yuumi Yoshida | |
| 11 | <pre> |
||
| 12 | new_item = "5/26,ランチ,-900" |
||
| 13 | file = open("book.txt", "a") |
||
| 14 | file.puts new_item |
||
| 15 | file.close |
||
| 16 | </pre> |
||
| 17 | |||
| 18 | h2. Deploy手順 |
||
| 19 | 1 | Yuumi Yoshida | |
| 20 | 多少手順がかわる事があります、当日一緒に操作して行きましょう。 |
||
| 21 | |||
| 22 | h4. 0. SSHキーの作成 |
||
| 23 | |||
| 24 | 既にあれば1. へ |
||
| 25 | |||
| 26 | <pre> |
||
| 27 | $ ls -al ~/.ssh # SSHキーの確認 |
||
| 28 | $ ssh-keygen |
||
| 29 | # キー入力がありますが全てENTER |
||
| 30 | </pre> |
||
| 31 | |||
| 32 | |||
| 33 | h4. 1. Herokuにアカウントを作成 |
||
| 34 | |||
| 35 | # https://www.heroku.com のSign Upで登録 |
||
| 36 | # Heroku Toolbelt をダウンロードしインストール |
||
| 37 | |||
| 38 | h4. 2. Heroku にログイン |
||
| 39 | |||
| 40 | <pre> |
||
| 41 | $ heroku login |
||
| 42 | Enter your Heroku credentials. |
||
| 43 | Email: 登録したメールアドレス |
||
| 44 | Password (typing will be hidden): 登録したパスワード |
||
| 45 | Authentication successful. |
||
| 46 | </pre> |
||
| 47 | |||
| 48 | |||
| 49 | h4. 3. Procfileを作成 |
||
| 50 | |||
| 51 | Herokuサーバー上で実行するコマンドを書きます |
||
| 52 | |||
| 53 | <pre> |
||
| 54 | web: bundle exec ruby jyanken.rb -p $PORT |
||
| 55 | </pre> |
||
| 56 | |||
| 57 | 実行するプログラムの名前が *jyanken.rb* でない場合は自分のプログラム名に変更 |
||
| 58 | |||
| 59 | h4. 4. Git にコードを格納 |
||
| 60 | |||
| 61 | <pre> |
||
| 62 | $ git init |
||
| 63 | $ git add アプリのファイル Gemfile Gemfile.lock Procfile |
||
| 64 | $ git commit -m 'for deploy' |
||
| 65 | </pre> |
||
| 66 | |||
| 67 | h4. 5. アプリ用サーバーを作成 |
||
| 68 | |||
| 69 | <pre> |
||
| 70 | $ heroku create |
||
| 71 | </pre> |
||
| 72 | |||
| 73 | h4. 6. Herokuにデプロイ |
||
| 74 | |||
| 75 | <pre> |
||
| 76 | $ git push heroku master |
||
| 77 | </pre> |
||
| 78 | |||
| 79 | h4. 7. 成功したら、ブラウザーからアプリにアクセス |
||
| 80 | |||
| 81 | <pre> |
||
| 82 | $ heroku open |
||
| 83 | </pre> |