Create an instance via EC2 console.
git clone https://github.com/creationix/nvm.git ~/.nvm
source ~/.nvm/nvm.sh
nvm install 11.5
(11.5 is the latest version at the time of this writing)
npm install express -global
npm install express-generator -global
Details on initialising app: https://qiita.com/tsuyoshioshima/items/7a553c25f222333b9503 (in JP)
Editing/Uploading files remotely:
- Edit file via Atom: https://qiita.com/tkap/items/0fdb63123bf3dd94372e
- Upload a file to EC2 via command line: see following command.
scp -i path/to/pemfile path/to/local/file/to/copy [email protected]:/home/ec2-user/path/to/file/to/save
where XXX is your EC2 IP
The app terminates when we logs out from the terminal, if not daemonized.
To make app run without termination, use forever.js.
npm install forever -global
Details on how to start the app with forever: https://mi-rai.co.jp/blog/880 (in JP)
Details on initialisation: https://qiita.com/yujiro0102/items/0bc30ab0a73de62c4e2d
How to start/stop server: https://qiita.com/ume1126/items/7cef8cb2c19959d25cb5
I've got a domain on https://www.onamae.com/ (in JP).
Details here: https://qiita.com/nadonado/items/a7c32c94fef87b7db0d5 (in JP)
cd
sudo service nginx start
cd path/to/your/nodejs/app
forever start ./bin/www
cd path/to/your/nodejs/app
forever stop ./bin/www
cd
sudo nginx -s stop