2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

初学者がCloud9で作成したLaravelアプリをHerokuへデプロイ

Last updated at Posted at 2021-08-10

【開発環境】
php7.2
Laravel 6
Cloud9

Cloud9とGitHubを連携する

●Cloud9上でリポジトリを作成
cd cms
git init
git add -A
git commit -m "first commit"

●Github上にリモートリポジトリを作成
Githubのサイトから「New repository」をクリックして作成する。

●SSH認証
Cloud9からGithubにPushするためにSSH認証を行う。

1⃣以下のコマンドで公開鍵を作成
ssh-keygen -t rsa

2⃣以下のコマンドで公開鍵のid_rsa.pubファイルを呼び出しての内容をコピー(ssh-rsaから始まる部分を全てコピー)
less ~/.ssh/id_rsa.pub

3⃣Github→Setting→SSH Keysに張り付ける

●githubにpush
$ git push git@github.com:●●●●●●●●/●●●●●●.git master

●今後のために登録(詳細不明)
git remote add origin git@github.com:●●●●●●●●/●●●●●●.git

Cloud9とHerokuの連携・アプリ作成

●Cloud9とHerokuの連携
source <(curl -sL https://cdn.learnenough.com/heroku_install)
heroku --version
heroku login --interactive

●Cloud9のターミナルからHerokuapp作成
heroku create <アプリ名>

●Procfileの作成(これをやらないと最後にHerokuにアクセスできない。)

echo "web: vendor/bin/heroku-php-apache2 public/" > Procfile

MySQLの設定

heroku addons:add cleardb
heroku config

CLEARDB_DATABASE_URLにあるHerokuの環境変数を確認

mysql:[USERNAME]:[PASSWORD]@[DB_HOST(***.cleardb.com)]/[DATABASE]?reconnect=true

heroku config:set DB_CONNECTION=mysql DB_HOST=***.cleardb.com(or net) DB_PORT=3306 DB_DATABASE=*** DB_USERNAME=*** DB_PASSWORD=*** -a <アプリ名>>

Herokuにデプロイ

git add .
git commit -m "first commit"
git push heroku master

APP_KEYを設定
heroku config:set APP_KEY=$(php artisan key:generate --show)

2
0
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
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?