6
7

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 5 years have passed since last update.

[備忘録] Node.js関係

Last updated at Posted at 2016-05-20

自分の環境

  • Node.js v5.4.0
  • npm 3.3.12
  • Express 4

npm start をforeverする方法

$ forever start -c "npm start" ./

絶対パスだと、失敗した。なんでじゃろ

80PortでNode.jsを動かすベストプラクティス(in Linux)

$ sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000

80portでlistenするのではなく、80portから3000portへRedirectさせることで実現する

Express4でのproduction環境への切り替え

$ export NODE_ENV=production && node app.js

development環境に戻す時はこう

$ export NODE_ENV=development && node app.js

最初の環境構築(AWS Linux)

// gitをインストール
$ sudo yum install git

// nvmをインストール && パスを通しておく
$ git clone git@github.com:creationix/nvm.git ~/.nvm
$ source ~/.nvm/nvm.sh

// Node.jsとnpmをインストール(Stable)
$ nvm install stable
6
7
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
6
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?