LoginSignup
4
5

More than 5 years have passed since last update.

HerokuでExpressを動かす

Last updated at Posted at 2015-05-30

アカウント作成

まずは、Herokuの公式サイトでアカウント作成
https://www.heroku.com/

ログイン

// herokuをインストール
$ gem install heroku
$ heroku login
Enter your Heroku credentials.
Email: *******
Password (typing will be hidden):
Authentication successful.

Expressプロジェクト作成

// Expressの雛形ジェネレータをインストール
$ npm install express-generator -g
// Expressプロジェクト作成
$ express プロジェクト名

Herokuにアプリを作成

$ cd プロジェクト
$ git init
$ heroku create

heroku createでHeroku上にアプリが作成され、カレントディレクトリのremoteリポジトリに作成されたアプリが登録される。

Procfileを作成してデプロイ

以下の内容でプロジェクトルート直下にProcfileを作成。

web: node ./bin/www

デプロイ

$ git add .
$ git commit -m "initial commit"
$ git push heroku master

ブラウザで確認

$ heroku open

こんな感じでExpressのWelcomeページが表示されれば完了。
スクリーンショット 2015-05-31 0.10.41.png

ログを確認

$ heroku logs --tail

ローカルでもExpressを起動する

$ gem install foreman
$ foreman start web

これで、localhost:5000でアクセス可能になる。

参照

Getting Started with Node.js on Heroku
Node.js(Express) 事始め & Heroku へデプロイまでのメモ

4
5
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
4
5