Hello world(heroku)

2020/04/18

まずは Hello world

Hello world を表示してみる。

参考にさせていただいたサイトはこちら。 ありがとうございます。

heroku へログイン

$ heroku login
Enter your Heroku credentials.
Email: [email protected]
Password (typing will be hidden): 
Authentication successful.

Hello World のファイルを作る

$ cd ~/project
$ mkdir heroku
$ cd heroku
$ touch composer.json
$ echo "echo 'Hello World';" > index.php

git リポジトリをつくる

$ git init
Initialized empty Git repository in /home/miyamiya/projects/heroku/.git/
$ git add .
$ git commit -m "Heroku test"
[master (root-commit) ea6ab95] Heroku test
 2 files changed, 2 insertions(+)
 create mode 100644 composer.json
 create mode 100644 index.php

環境作成

$ heroku create
Creating アプリケーション名... done, stack is cedar
https://アプリケーション名.herokuapp.com/ | [email protected]:アプリケーション名.git
Git remote heroku added

deploy

$ git push heroku master
The authenticity of host 'heroku.com (50.19.85.154)' can't be established.
RSA key fingerprint is XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'heroku.com,50.19.85.154' (RSA) to the list of known hosts.
Initializing repository, done.
Counting objects: 4, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (4/4), 284 bytes | 0 bytes/s, done.
Total 4 (delta 0), reused 0 (delta 0)

-----> PHP app detected

       NOTICE: Your composer.json is completely empty.
       Please change its contents to at least "{}" so it is valid JSON.

-----> No runtime requirements in composer.json, defaulting to PHP 5.6.2.
-----> Installing system packages...
       - PHP 5.6.2
       - Apache 2.4.10
       - Nginx 1.6.0
-----> Installing PHP extensions...
       - zend-opcache (automatic; bundled, using 'ext-zend-opcache.ini')
-----> Installing dependencies...
       Composer version 1.0-dev (a309e1d89ded6919935a842faeaed8e888fbfe37) 2014-10-20 19:16:14
       Loading composer repositories with package information
       Installing dependencies
       Nothing to install or update
       Generating optimized autoload files
-----> Preparing runtime environment...
       NOTICE: No Procfile, defaulting to 'web: vendor/bin/heroku-php-apache2'
-----> Discovering process types
       Procfile declares types -> web

-----> Compressing... done, 69.3MB
-----> Launching... done, v3
       https://アプリケーション名.herokuapp.com/ deployed to Heroku

To [email protected]:アプリケーション名.git
 * [new branch]      master -> master

動作確認

$ heroku open
Opening アプリケーション名... done

自動的にブラウザが起動する。