LoginSignup
5

More than 3 years have passed since last update.

Herokuでwebサービス公開方法と削除方法

Last updated at Posted at 2019-04-21

heroku-cilをインストール

$ wget https://cli-assets.heroku.com/heroku-linux-x64.tar.gz -O heroku.tar.gz
$ sudo mkdir -p /usr/local/lib/heroku
$ sudo tar --strip-components 1 -zxvf heroku.tar.gz -C /usr/local/lib/heroku
$ sudo ln -s /usr/local/lib/heroku/bin/heroku /usr/local/bin/heroku

ターミナルでログイン

$ heroku login -i
  • Heorkuに登録したemail,passwordを入力する

アプリ作成

$ cd messge-board
$ heroku create message-board

アプリが作成されたか確認

$ heroku apps

gitにリモートリポジトリが作成されているか確認

$ git remote -v

設定変更

  • Herokuの標準DBがPostgreSQLなため設定が必要
gemfile
  • Production環境で、pgを使うとこを指定
  • pgとはrailsとPostgreSQLを連携するためのGem
group :production do
  gem "pg", ">= 0.18", "< 2.0"
end
$ bundle install --without production
(config/database.yml)
  • production環境の設定を**PostgreSQLに変更
production:
  adapter: postgresql
  encoding: unicode
  pool: 5
  database: message-board_production
  username: message-board
  password: <%= ENV['MESSAGE-BOARD_DATABASE_PASSWORD'] %>

デプロイ

$ git add .
$ git commit -m "for heroku"
$ git push heroku master
$ heroku run rails db:migrate

アプリの削除

$ heroku apps:destroy --app アプリ名
  • もう一度アプリ名を入力する
  • アプリとリモートリポジトリが削除される

ついで

 Warning: heroku update available from 7.25.0 to 7.29.0.

これは新しいバージョンにアップデートしてね!と言われている

heroku update

これでOK!

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
5