AWS EC2 서버 배포하기

박주엽·2020년 8월 30일
0

AWS

목록 보기
1/1

1.기존 키로 해당 서버에 접속하기

ssh -i 키가있는 폴더/dooreplay.pem ubuntu@13.124.97.235

2.node,npm 설치

새로 node와 npm을 설치해준다.
curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
sudo apt-get install nodejs

3.버전 확인

npm -v
node -v

4. project clone

git clone 프로젝트 깃 주소

5. npm 설치

npm install

6. express

yarn add express

7. 로컬서버 변경

vi server.js

const http = require("http");
const express = require("express");
const path = require("path");

const app = express();

const port = 8000;

app.get("/ping", (req, res) => {
  res.send("pong");
});

app.use(express.static(path.join(__dirname, "build")));

app.get("/*", (req, res) => {
  res.set({
    "Cache-Control": "no-cache, no-store, must-revalidate",
    Pragma: "no-cache",
    Date: Date.now()
  });
  res.sendFile(path.join(__dirname, "build", "index.html"));
});

http.createServer(app).listen(port, () => {
  console.log(`app listening at ${port}`);
});

8.build

sudo yarn build
node server.js
node server.js &서버를 꺼도 서버는 살아있음

0개의 댓글