Introduction
This document is a weak memorandum for my cheap working job
connect AWS EC2 instnce
connect by SSH to Linux instance from ec2-user
- push [Connect (接続) ] buttom below
![スクリーンショット 2020-05-12 0.22.29.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.ap-northeast-1.amazonaws.com%2F0%2F124810%2Fc361263e-71ef-2f96-321e-cc87f825d77c.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=2361beafd510522584d2be69de97fe5e)
use EC2 Instance Connect (browser base SSH conection)
- select
EC2 Instance Connect
and push [Connect (接続) ] buttom below
![スクリーンショット 2020-05-12 0.23.20.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.ap-northeast-1.amazonaws.com%2F0%2F124810%2F3352adb3-0e84-a60f-6609-84bc7dc4a6ad.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=71bc54f47cdd584f3b73c9dcb5dcbd20)
install Node.js
install nvm (node version manager)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
activate nvm
. ~/.nvm/nvm.sh
install recent version of Node.js
nvm install node
test for correct Node.js install and execute
node -e "console.log('Running Node.js ' + process.version)"
then display below on terminal
Running Node.js VERSION
install Express web framework for Node.js
make service directory and change this directory
mkdir dev/nodejs/express/app
cd dev/nodejs/express/app
Node.js project initialization
npm init -y
install Node.js web framework Express
npm install --save express
then create node_modules
folder and setting lock file package-lock.json
install Express-Generator that create web application template library for express framework
install Express-Generator and create a template
npm install -g express-generator
create web application template that name is members
express --view=ejs members
move directory for web application template and install
cd members
npm install
test running express web application
npm start
then display terminal blow
> members@0.0.0 start /home/ec2-user/dev/nodejs/express/app/members
> node ./bin/www
open inbound port 3000 on AWS EC2 security group
- click security group link anchor
![スクリーンショット 2020-05-12 21.46.01.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.ap-northeast-1.amazonaws.com%2F0%2F124810%2Fbdfda559-30f1-1214-1a1f-a0bd53d91684.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=18dda9cfee27376a25a36ec90561a359)
- then click [edit inbound rule (インバウンドルールの編集)] button
- add rule below
type(タイプ) | port area(ポート範囲) | source(ソース) |
---|---|---|
custom TCP | 3000 | 0.0.0.0/0 |
![スクリーンショット 2020-05-12 21.21.24.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.ap-northeast-1.amazonaws.com%2F0%2F124810%2Fde5ae0fd-79df-647b-277d-d3a02ed69a9e.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=302faf6f171225d2ba155c9cb429df30)
access web browser to URL
http://public DNS:3000/
- public DNS is about
- ec2-xx-xxx-xxx-xx.ap-northeast-1.compute.amazonaws.com
then display web browser blow
![スクリーンショット 2020-05-12 21.22.23.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.ap-northeast-1.amazonaws.com%2F0%2F124810%2F737768a6-b0ea-ca91-d386-21b156e4b9b9.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=b9844d79f7ea3bdc5d6a97e64ee82fd7)