LoginSignup
0
1

More than 1 year has passed since last update.

Heroku利用方法[Windows]

Last updated at Posted at 2022-05-17

目次

  1. 事前準備
  2. Herokuの利用
  3. Herokuの運用
  4. データベースの利用

1. 事前準備

Gitインストール

こちらを参考にしながら、Gitをインストールします。
私はすべてデフォルトでインストールしました。

Herokuアカウントを作成

こちらから、「無料で新規登録」より作成できます。

HerokuCLIインストール

こちらからインストールできます。
CLI -> Command Line Interface

2. Herokuを利用

Heroku環境構築

heroku login  # ログインページが起動するので、アカウントを入力する
heroku create <アプリ名>  # アプリを作るフォルダーを作成する
# 環境変数の設定
heroku config:set <ValiableName>=<"設定する値"> --app <アプリ名>

作成したアプリをHerokuに上げる

特定のフォルダーに移動し、以下を実行。

git init  # 共有レポジトリ新規作成
git add .  # フォルダ内のすべてをコミットするデータとして予約する
git commit -m "My first commit"  # 変更データ保存
heroku git:remote -a <APP NAME>    # Herokuとgitを結びつける
git push heroku master # Herokuへ送信

ログの確認

エラーでも色が変わらないので注意する。

heroku logs --app <アプリ名>  # アプリのログを表示する

3. Herokuの運用

作成したアプリのソースコードを取得

# ローカルに複製
heroku git:clone --app <アプリ名>
# 最新データを取得
git pull

変更を反映させる

git add .    # フォルダ内すべてをcommit予約
git commit -m "Second_commit"    # 変更をレポジトリへ保存
git push heroku master    # Herokuへ送信

4. データベースの利用

Herokuでは※1sqliteが使えないので、Postgresを利用する。
※1.Herokuは定期的にに最後にcommitした状態に戻るため、作成された.dbは消える。

データベースの作成

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1