herokuにただのWebページを乗せてみる

無料で利用できるPaaSはAWS、GAEなどありますが、AWSは溢れると有料でしかも1年間だけ、GAEは溢れると有料になったりするので、調べてみるとherokuが良さそう。

お試しサイトを作成して人に見てもらう時に重宝する。
で、Windowsにおける、herokuのSignUp後の作業を書いてみる。


まず、公開したいローカルのフォルダに移動

C:\>cd C:\WebRoot\Test01

gitの管理ファイルを作る

C:\WebRoot\Test01>git init
Initialized empty Git repository in C:/WebRoot/Test01/.git/

gitにCommit

C:\WebRoot\Test01>git add .
C:\WebRoot\Test01>git commit -m "init"
[master (root-commit) ea00eb8] init
 2 files changed, 18 insertions(+), 0 deletions(-)
 create mode 100644 .project
 create mode 100644 test/test.html

herokuのファイルを作る

C:\WebRoot\Test01>heroku create
Creating smooth-flower-xxxx... done, stack is cedar
http://smooth-flower-xxxx.herokuapp.com/ | git@heroku.com:smooth-flower-xxxx.git
Git remote heroku added

herokuのVersionを最新化

C:\WebRoot\Test01>heroku update
Updating from 2.28.12... done, updated to 2.28.12

公開鍵を教える

C:\WebRoot\Test01>heroku keys:add "C:/Users/name/.ssh/id_rsa.pub"
Uploading SSH public key C:/Users/name/.ssh/id_rsa.pub... done

index.phpがないと怒られる。エラーメッセージからは推測不可能な所がキモい。

C:\WebRoot\Test01>git push heroku master
Enter passphrase for key '/c/Users/name/.ssh/id_rsa':
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 489 bytes, done.
Total 5 (delta 0), reused 0 (delta 0)

          • > Heroku receiving push
! Heroku push rejected, no Cedar-supported app detected To git@heroku.com:smooth-flower-xxxx.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'git@heroku.com:smooth-flower-xxxx.git'

index.phpをgitにpushする

C:\WebRoot\Test01>git add index.php
C:\WebRoot\Test01>git commit -m "add index.php"
[master cf92486] add index.php
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 index.php

herokuへ

C:\WebRoot\Test01>git push heroku master
Enter passphrase for key '/c/Users/name/.ssh/id_rsa':
Counting objects: 8, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (8/8), 762 bytes, done.
Total 8 (delta 0), reused 0 (delta 0)

          • > Heroku receiving push
          • > PHP app detected
          • > Bundling Apache version 2.2.22
          • > Bundling PHP version 5.3.10
          • > Discovering process types
Procfile declares types -> (none) Default types for PHP -> web
          • > Compiled slug size is 9.5MB
          • > Launching... done, v3
http://smooth-flower-xxxx.herokuapp.com deployed to Heroku To git@heroku.com:smooth-flower-xxxx.git * [new branch] master -> master

上記URL(http://smooth-flower-xxxx.herokuapp.com)をブラウザからアクセスすると見える。
phpは使わなければ良い。