参考にさせて頂いたページ
今日の環境
- Windows10 Home
- Heroku CLI 6.14.36
アカウント作成
アカウント作成はすぐできました。
参考にさせて頂いたページはスクリーンショットも付いて解りやすいですね。
クライアントツールをダウンロード
「Heroku CLI | Heroku Dev Center」から、heroku-cli-x64.exeのダウンロードをしてインストールしました。
Heroku CLI 6.14.36 がインストールされました。
任意のディレクトリにgit cloneする
あらかじめbitbucketで作成しておいた空のリポジトリをcloneしました。
index.phpを作成してコミット
以下の通り作成してコミットしました。
<!DOCTYPE html> <html> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>sample</title> <meta charset="utf-8"> </head> <body> Hello World </body> </html>
Herokuにログインする
上記のcloneしたディレクトリにコマンドプロンプトで移動して、以下のコマンドを実行しました。
heroku login
以下のような表示でEmailとPasswordを入力したらログインできました。
Enter your Heroku credentials: Email: Password: Logged in as <your mail address>
Herokuアプリケーションを作成する
以下のコマンドを実行しました。
heroku create
以下のような表示がされて、アプリケーションが作成されました。
Creating app... done, cryptic-stream-72356 https://cryptic-stream-72356.herokuapp.com/ | https://git.heroku.com/cryptic-stream-72356.git
デプロイする
上記した手順でindex.phpを作成しているわけですが、index.htmlを作成したらpushに失敗したからindex.phpにしているという経緯もあります。
以下のコマンドでHerokuのサーバにデプロイします。
git push heroku master
以下のように表示されました。
Counting objects: 6, done. Delta compression using up to 4 threads. Compressing objects: 100% (5/5), done. Writing objects: 100% (6/6), 985 bytes | 0 bytes/s, done. Total 6 (delta 0), reused 0 (delta 0) remote: Compressing source files... done. remote: Building source: remote: remote: -----> PHP app detected remote: remote: ! WARNING: No 'composer.json' found. remote: Using 'index.php' to declare app type as PHP is considered legacy remote: functionality and may lead to unexpected behavior. remote: remote: -----> Bootstrapping... remote: -----> Installing platform packages... remote: NOTICE: No runtime required in composer.lock; using PHP ^5.5.17 remote: - apache (2.4.20) remote: - nginx (1.8.1) remote: - php (5.6.31) remote: -----> Installing dependencies... remote: Composer version 1.5.2 2017-09-11 16:59:25 remote: -----> Preparing runtime environment... remote: NOTICE: No Procfile, using 'web: heroku-php-apache2'. remote: -----> Checking for additional extensions to install... remote: -----> Discovering process types remote: Procfile declares types -> web remote: remote: -----> Compressing... remote: Done: 13.7M remote: -----> Launching... remote: Released v3 remote: https://cryptic-stream-72356.herokuapp.com/ deployed to Heroku remote: remote: Verifying deploy... done. To https://git.heroku.com/cryptic-stream-72356.git * [new branch] master -> master
ページを表示してみる
以下のURLにアクセスしたらデプロイしたページが表示されました。
https://cryptic-stream-72356.herokuapp.com/
アプリケーション名を変更する
他の人がまだ使用していない名前に変更できるようです。
以下のコマンドで変更します。
xxxxの部分は任意で名前を設定してください。
記号はハイフンだけが使用できるようです。
heroku rename xxxx
でページが表示できるようになります。
Herokuからログアウトする
以下のコマンドでログアウトします。
heroku logout
gitのoriginとherokuを確認しておく
以下のコマンドを実行しました。
git config --list