NestJS로 EC2 배포하기

원민관·2025년 9월 1일

deployment

목록 보기
2/7
post-thumbnail

EC2 접속 ✅

  1. pem 키가 있는 경로로 이동 🟣
(base) wonminkwan@wonmingwan-ui-MacBookAir ~ % cd desktop

⚠️ 로컬 컴퓨터에서 SSH 접속에 필요한 비밀 키 파일이 저장된 위치로 이동했습니다. 바탕화면에 키 파일이 있어서 desktop 경로로 이동했습니다.

  1. chmod 400 <Key파일명>.pem 🟣
(base) wonminkwan@wonmingwan-ui-MacBookAir desktop % chmod 400 pullim-key.pem

⚠️ chmod 400은 위 비밀 키 파일을 소유자만 읽을 수 있도록 권한을 변경하는 보안 조치입니다. 이 과정을 거치지 않으면 SSH 접속이 거부됩니다.

  1. ssh -i <Key파일명>.pem ec2-user@<EC2퍼블릭IP> 🟣
(base) wonminkwan@wonmingwan-ui-MacBookAir desktop % ssh -i pullim-key.pem ec2-user@<비밀>

⚠️ SSH를 통해 EC2 인스턴스에 접속합니다. -i 옵션으로 pem 키를 저장하고, ec2-user 계정으로 EC2의 Public IP 주소에 접속합니다.

  1. yes 치고 엔터 🟣
   ,     #_
   ~\_  ####_        Amazon Linux 2023
  ~~  \_#####\
  ~~     \###|
  ~~       \#/ ___   https://aws.amazon.com/linux/amazon-linux-2023
   ~~       V~' '->
    ~~~         /
      ~~._.   _/
         _/ _/
       _/m/'
Last login: Mon Sep  1 10:27:41 2025 from 13.209.1.61

⚠️ 접속에 성공했음을 의미합니다.

Linux에서 설치해야 할 것들 ✅

  1. sudo dnf update -y 🟣
[ec2-user@ip-172-31-33-23 ~]$ sudo dnf update -y
Amazon Linux 2023 Kernel Livepatch repository                            172 kB/s |  19 kB     00:00    
Dependencies resolved.
Nothing to do.
Complete!

⚠️ dnf update는 서버에 설치된 모든 소프트웨어 패키지를 최신 버전으로 업데이트하여 보안 및 안정성을 확보하는 작업입니다.

  1. curl -fsSL https://rpm.nodesource.com/setup_22.x | sudo bash - 🟣
[ec2-user@ip-172-31-33-23 ~]$ curl -fsSL https://rpm.nodesource.com/setup_22.x | sudo bash -
2025-09-01 11:21:09 - Cleaning up old repositories...
2025-09-01 11:21:09 - Old repositories removed
2025-09-01 11:21:09 - Supported architecture: x86_64
2025-09-01 11:21:09 - Added N|Solid repository for LTS version: 22.x
2025-09-01 11:21:09 - dnf available, updating...
Node.js Packages for Linux RPM based distros - x86_64                    9.1 MB/s | 727 kB     00:00    
Metadata cache created.
N|Solid Packages for Linux RPM based distros - x86_64                    4.6 MB/s | 353 kB     00:00    
Metadata cache created.
2025-09-01 11:21:10 - Repository is configured and updated.
2025-09-01 11:21:10 - You can use N|solid Runtime as a node.js alternative
2025-09-01 11:21:10 - To install N|solid Runtime, run: dnf install nsolid -y
2025-09-01 11:21:10 - Run 'dnf install nodejs -y' to complete the installation.

⚠️ Amazon Linux의 기본 저장소보다 더 최신 버전의 Node.js(v22)를 설치하기 위해, NodeSource라는 공식 외부 저장소를 시스템에 추가합니다.

  1. sudo dnf install -y nodejs git 🟣
[ec2-user@ip-172-31-33-23 ~]$ sudo dnf install -y nodejs git
Last metadata expiration check: 0:00:36 ago on Mon Sep  1 11:21:10 2025.
Dependencies resolved.
=========================================================================================================
 Package                 Architecture  Version                            Repository                Size
=========================================================================================================
Installing:
 git                     x86_64        2.50.1-1.amzn2023.0.1              amazonlinux               53 k
 nodejs                  x86_64        2:22.19.0-1nodesource              nodesource-nodejs         44 M
Installing dependencies:
 git-core                x86_64        2.50.1-1.amzn2023.0.1              amazonlinux              4.9 M
 git-core-doc            noarch        2.50.1-1.amzn2023.0.1              amazonlinux              2.8 M
 perl-Error              noarch        1:0.17029-5.amzn2023.0.2           amazonlinux               41 k
 perl-File-Find          noarch        1.37-477.amzn2023.0.7              amazonlinux               25 k
 perl-Git                noarch        2.50.1-1.amzn2023.0.1              amazonlinux               41 k
 perl-TermReadKey        x86_64        2.38-9.amzn2023.0.2                amazonlinux               36 k
 perl-lib                x86_64        0.65-477.amzn2023.0.7              amazonlinux               15 k

Transaction Summary
=========================================================================================================
Install  9 Packages

Total download size: 52 M
Installed size: 170 M
Downloading Packages:
(1/9): git-2.50.1-1.amzn2023.0.1.x86_64.rpm                              943 kB/s |  53 kB     00:00    
(2/9): git-core-2.50.1-1.amzn2023.0.1.x86_64.rpm                          49 MB/s | 4.9 MB     00:00    
(3/9): perl-Error-0.17029-5.amzn2023.0.2.noarch.rpm                      2.0 MB/s |  41 kB     00:00    
(4/9): git-core-doc-2.50.1-1.amzn2023.0.1.noarch.rpm                      35 MB/s | 2.8 MB     00:00    
(5/9): perl-File-Find-1.37-477.amzn2023.0.7.noarch.rpm                   1.3 MB/s |  25 kB     00:00    
(6/9): perl-TermReadKey-2.38-9.amzn2023.0.2.x86_64.rpm                   1.7 MB/s |  36 kB     00:00    
(7/9): perl-Git-2.50.1-1.amzn2023.0.1.noarch.rpm                         1.5 MB/s |  41 kB     00:00    
(8/9): perl-lib-0.65-477.amzn2023.0.7.x86_64.rpm                         722 kB/s |  15 kB     00:00    
(9/9): nodejs-22.19.0-1nodesource.x86_64.rpm                              88 MB/s |  44 MB     00:00    
---------------------------------------------------------------------------------------------------------
Total                                                                     98 MB/s |  52 MB     00:00     
Node.js Packages for Linux RPM based distros - x86_64                    133 kB/s | 3.1 kB     00:00    
Importing GPG key 0x3AF28A14:
 Userid     : "Nodesource Operations <operations@nodesource.com>"
 Fingerprint: 242B 8138 31AF 0956 2B6C 46F7 6B88 DA4E 3AF2 8A14
 From       : https://rpm.nodesource.com/gpgkey/ns-operations-public.key
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                 1/1 
  Installing       : git-core-2.50.1-1.amzn2023.0.1.x86_64                                           1/9 
  Installing       : git-core-doc-2.50.1-1.amzn2023.0.1.noarch                                       2/9 
  Installing       : perl-lib-0.65-477.amzn2023.0.7.x86_64                                           3/9 
  Installing       : perl-TermReadKey-2.38-9.amzn2023.0.2.x86_64                                     4/9 
  Installing       : perl-File-Find-1.37-477.amzn2023.0.7.noarch                                     5/9 
  Installing       : perl-Error-1:0.17029-5.amzn2023.0.2.noarch                                      6/9 
  Installing       : perl-Git-2.50.1-1.amzn2023.0.1.noarch                                           7/9 
  Installing       : git-2.50.1-1.amzn2023.0.1.x86_64                                                8/9 
  Running scriptlet: nodejs-2:22.19.0-1nodesource.x86_64                                             9/9 
  Installing       : nodejs-2:22.19.0-1nodesource.x86_64                                             9/9 
  Running scriptlet: nodejs-2:22.19.0-1nodesource.x86_64                                             9/9 
  Verifying        : nodejs-2:22.19.0-1nodesource.x86_64                                             1/9 
  Verifying        : git-2.50.1-1.amzn2023.0.1.x86_64                                                2/9 
  Verifying        : git-core-2.50.1-1.amzn2023.0.1.x86_64                                           3/9 
  Verifying        : git-core-doc-2.50.1-1.amzn2023.0.1.noarch                                       4/9 
  Verifying        : perl-Error-1:0.17029-5.amzn2023.0.2.noarch                                      5/9 
  Verifying        : perl-File-Find-1.37-477.amzn2023.0.7.noarch                                     6/9 
  Verifying        : perl-Git-2.50.1-1.amzn2023.0.1.noarch                                           7/9 
  Verifying        : perl-TermReadKey-2.38-9.amzn2023.0.2.x86_64                                     8/9 
  Verifying        : perl-lib-0.65-477.amzn2023.0.7.x86_64                                           9/9 

Installed:
  git-2.50.1-1.amzn2023.0.1.x86_64                   git-core-2.50.1-1.amzn2023.0.1.x86_64              
  git-core-doc-2.50.1-1.amzn2023.0.1.noarch          nodejs-2:22.19.0-1nodesource.x86_64                
  perl-Error-1:0.17029-5.amzn2023.0.2.noarch         perl-File-Find-1.37-477.amzn2023.0.7.noarch        
  perl-Git-2.50.1-1.amzn2023.0.1.noarch              perl-TermReadKey-2.38-9.amzn2023.0.2.x86_64        
  perl-lib-0.65-477.amzn2023.0.7.x86_64             

Complete!

⚠️ dnf install 명령어로 Node.js(서버 실행 환경)와 Git(GitHub에서 코드 다운로드)을 실제로 설치합니다.

  1. sudo corepack enable 🟣

⚠️ corepack은 Node.js에 내장된 패키지 매니저 관리 도구입니다. 이 명령어로 yarn이나 pnpm 같은 도구를 쉽게 사용할 수 있도록 활성화합니다.

  1. corepack prepare yarn@stable --activate 🟣
[ec2-user@ip-172-31-33-23 ~]$ corepack prepare yarn@stable --activate
Preparing yarn@stable for immediate activation...

⚠️ corepack을 통해 최신 안정화 버전의 Yarn을 다운로드하고 시스템의 기본 yarn 명령어로 사용할 수 있도록 설정합니다.

설치 확인 ✅

  1. node -v 🟣
[ec2-user@ip-172-31-33-23 ~]$ node -v
v22.19.0
  1. npm -v 🟣
[ec2-user@ip-172-31-33-23 ~]$ npm -v
10.9.3
  1. yarn -v 🟣
[ec2-user@ip-172-31-33-23 ~]$ yarn -v
4.9.4
  1. git --version 🟣
[ec2-user@ip-172-31-33-23 ~]$ git --version
git version 2.50.1

Github에서 프로젝트 clone ✅

  1. git clone <레포지토리_URL> 🟣
[ec2-user@ip-172-31-33-23 ~]$ git clone https://github.com/minkwan-1/react-nest.git
Cloning into 'react-nest'...
remote: Enumerating objects: 6891, done.
remote: Counting objects: 100% (912/912), done.
remote: Compressing objects: 100% (621/621), done.
remote: Total 6891 (delta 515), reused 582 (delta 266), pack-reused 5979 (from 2)
Receiving objects: 100% (6891/6891), 10.50 MiB | 21.59 MiB/s, done.
Resolving deltas: 100% (4512/4512), done.

⚠️ 지정된 GitHub Repository URL에서 프로젝트 전체 코드를 EC2 서버로 복제합니다.

  1. cd <프로젝트백엔드폴더> 🟣
[ec2-user@ip-172-31-33-23 ~]$ ls -l
total 0
drwxr-xr-x. 5 ec2-user ec2-user 86 Sep  1 11:34 react-nest
[ec2-user@ip-172-31-33-23 ~]$ cd server
-bash: cd: server: No such file or directory
[ec2-user@ip-172-31-33-23 ~]$ cd react-nest
[ec2-user@ip-172-31-33-23 react-nest]$ cd server

⚠️ git clone으로 생성된 react-nest 폴더로 이동한 후, 실제 백엔드 코드가 있는 server 폴더로 이동합니다.

  1. 스왑 파일 설정 🟣
# 2GB 스왑 파일 생성
sudo dd if=/dev/zero of=/swapfile bs=1M count=2048
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

# 스왑 활성화 확인 (Swap 부분에 2.0G 정도 나와야 함)
free -h

⚠️ EC2의 저사양 인스턴스는 메모리(RAM)가 부족하여 yarn install이나 yarn build 과정에서 멈추거나 실패할 수 있습니다. 이를 방지하기 위해 하드 디스크의 일부를 '가상 메모리'처럼 사용하는 스왑 파일을 설정합니다.

  1. yarn install 🟣
[ec2-user@ip-172-31-33-23 server]$ yarn install
➤ YN0000: · Yarn 4.9.4
➤ YN0000: ┌ Resolution step
➤ YN0085: │ + @google/generative-ai@npm:0.21.0, @nestjs/axios@npm:3.1.3, @nestjs/cli@npm:10.4.9, and 914 more.
➤ YN0000: └ Completed in 2s 842ms
➤ YN0000: ┌ Post-resolution validation
➤ YN0060: │ @nestjs/common is listed by your project with version 10.4.15 (p1380ce), which doesn't satisfy what @nestjs/swagger and other dependencies request (but they have non-overlapping ranges!).
➤ YN0060: │ @nestjs/core is listed by your project with version 10.4.15 (pdd5bcc), which doesn't satisfy what @nestjs/swagger and other dependencies request (but they have non-overlapping ranges!).
➤ YN0002: │ server@workspace:. doesn't provide axios (p2946b1), requested by @nestjs/axios.
➤ YN0002: │ server@workspace:. doesn't provide webpack (p9ae82f), requested by ts-loader.
➤ YN0086: │ Some peer dependencies are incorrectly met by your project; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code.
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0013: │ 602 packages were added to the project (+ 313.29 MiB).
➤ YN0000: └ Completed in 19s 926ms
➤ YN0000: ┌ Link step
➤ YN0007: │ @nestjs/core@npm:10.4.15 [48fd9] must be built because it never has been before or the last one failed
➤ YN0007: │ aws-sdk@npm:2.1692.0 must be built because it never has been before or the last one failed
➤ YN0007: │ bcrypt@npm:5.1.1 must be built because it never has been before or the last one failed
➤ YN0007: │ sharp@npm:0.34.2 must be built because it never has been before or the last one failed
➤ YN0007: │ @scarf/scarf@npm:1.4.0 must be built because it never has been before or the last one failed
➤ YN0000: └ Completed in 23s 426ms
➤ YN0000: · Done with warnings in 46s 463ms

⚠️ package.json 파일에 명시된 프로젝트에 필요한 모든 라이브러리(의존성)들을 node_modules 폴더에 설치합니다.

  1. yarn build 🟣
[ec2-user@ip-172-31-33-23 server]$ yarn build
[ec2-user@ip-172-31-33-23 server]$ ls -l
total 788
-rw-r--r--.   1 ec2-user ec2-user   5213 Sep  1 11:34 README.md
-rw-r--r--.   1 ec2-user ec2-user     86 Sep  1 11:34 data-source.d.ts
-rw-r--r--.   1 ec2-user ec2-user   1188 Sep  1 11:34 data-source.js
-rw-r--r--.   1 ec2-user ec2-user    506 Sep  1 11:34 data-source.js.map
-rw-r--r--.   1 ec2-user ec2-user   1000 Sep  1 11:34 data-source.ts
drwxr-xr-x.   3 ec2-user ec2-user    123 Sep  1 12:15 dist
-rw-r--r--.   1 ec2-user ec2-user    171 Sep  1 11:34 nest-cli.json
drwxr-xr-x. 645 ec2-user ec2-user  32768 Sep  1 12:15 node_modules
-rw-r--r--.   1 ec2-user ec2-user   3044 Sep  1 11:34 package.json
drwxr-xr-x.   2 ec2-user ec2-user     36 Sep  1 11:34 public
-rw-r--r--.   1 ec2-user ec2-user   8904 Sep  1 11:34 schema.sql
drwxr-xr-x.   2 ec2-user ec2-user     35 Sep  1 11:34 scripts
drwxr-xr-x.   6 ec2-user ec2-user    100 Sep  1 11:34 src
drwxr-xr-x.   2 ec2-user ec2-user     50 Sep  1 11:34 test
-rw-r--r--.   1 ec2-user ec2-user     97 Sep  1 11:34 tsconfig.build.json
-rw-r--r--.   1 ec2-user ec2-user 368728 Sep  1 11:34 tsconfig.build.tsbuildinfo
-rw-r--r--.   1 ec2-user ec2-user    645 Sep  1 11:34 tsconfig.json
-rw-r--r--.   1 ec2-user ec2-user 329182 Sep  1 12:14 yarn.lock

⚠️ TypeScript(.ts)로 작성된 소스 코드를 Node.js가 직접 실행할 수 있는 JavaScript(.js) 코드로 변환(컴파일)합니다. 결과물은 dist 폴더에 저장됩니다.

.env 파일 직접 생성 ✅

  1. nano .env 🟣

⚠️ nano는 간단한 텍스트 편집기입니다. .env라는 이름의 새 파일을 생성하고 편집 모드로 들어갑니다.

  1. (nano 편집기 안에서 아래 내용 입력 후 Ctrl+O, Enter, Ctrl+X)
    PORT=80 🟣

⚠️ PORT=80을 입력하여 서버가 80번 포트에서 실행되도록 설정합니다. 80번은 웹 브라우저의 기본 HTTP 포트입니다.
(입력 후 Ctrl+O → Enter로 저장, Ctrl+X로 편집기 종료)

pm2 설치 후 서버 실행 ✅

  1. sudo yarn global add pm2 🟣
.
.
.
success Installed "pm2@6.0.8" with binaries:
      - pm2
      - pm2-dev
      - pm2-docker
      - pm2-runtime
Done in 5.95s.

⚠️ Node.js 서버를 안정적으로 24시간 운영하기 위해 프로세스 매니저인 pm2를 설치하고 설정하는 과정입니다. pm2는 서버가 꺼지면 자동으로 재시작해주고, 백그라운드에서 계속 실행되도록 관리해주는 강력한 도구입니다.

  1. pm2 start dist/src/main.js --name nest-server 🟣
[ec2-user@ip-172-31-33-23 server]$ pm2 start dist/src/main.js --name nest-server

                        -------------

__/\\\\\\\\\\\\\____/\\\\____________/\\\\____/\\\\\\\\\_____
 _\/\\\/////////\\\_\/\\\\\\________/\\\\\\__/\\\///////\\\___
  _\/\\\_______\/\\\_\/\\\//\\\____/\\\//\\\_\///______\//\\\__
   _\/\\\\\\\\\\\\\/__\/\\\\///\\\/\\\/_\/\\\___________/\\\/___
    _\/\\\/////////____\/\\\__\///\\\/___\/\\\________/\\\//_____
     _\/\\\_____________\/\\\____\///_____\/\\\_____/\\\//________
      _\/\\\_____________\/\\\_____________\/\\\___/\\\/___________
       _\/\\\_____________\/\\\_____________\/\\\__/\\\\\\\\\\\\\\\_
        _\///______________\///______________\///__\///////////////__


                          Runtime Edition

        PM2 is a Production Process Manager for Node.js applications
                     with a built-in Load Balancer.

                Start and Daemonize any application:
                $ pm2 start app.js

                Load Balance 4 instances of api.js:
                $ pm2 start api.js -i 4

                Monitor in production:
                $ pm2 monitor

                Make pm2 auto-boot at server restart:
                $ pm2 startup

                To go further checkout:
                http://pm2.io/


                        -------------

[PM2] Spawning PM2 daemon with pm2_home=/home/ec2-user/.pm2
[PM2] PM2 Successfully daemonized
[PM2] Starting /home/ec2-user/react-nest/server/dist/src/main.js in fork_mode (1 instance)
[PM2] Done.
┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐
│ id │ name               │ mode     │ ↺    │ status    │ cpu      │ memory   │
├────┼────────────────────┼──────────┼──────┼───────────┼──────────┼──────────┤
│ 0  │ nest-server        │ fork     │ 0    │ online    │ 0%       │ 34.6mb   │
└────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘
[ec2-user@ip-172-31-33-23 server]$ 

⚠️ yarn build로 생성된 dist/src/main.js 파일을 nest-server라는 이름으로 백그라운드에서 실행시킵니다. 이제 터미널을 종료해도 서버는 계속 동작합니다.

  1. pm2 startup systemd 🟣
[ec2-user@ip-172-31-33-23 server]$ pm2 startup systemd
[PM2] Init System found: systemd
[PM2] To setup the Startup Script, copy/paste the following command:
sudo env PATH=$PATH:/usr/bin /usr/local/share/.config/yarn/global/node_modules/pm2/bin/pm2 startup systemd -u ec2-user --hp /home/ec2-user

⚠️ EC2 서버 자체가 재부팅될 때 pm2도 자동으로 시작되도록 설정하는 과정입니다. 이 명령어는 실제 설정을 위한 명령어를 생성해줍니다.

  1. sudo env PATH=PATH:/usr/bin/usrsudoenvPATH=PATH:/usr/bin /usrsudo env PATH=PATH:/usr/bin /usr/local/share/.config/yarn/global/node_modules/pm2/bin/pm2 startup systemd -u ec2-user --hp /home/ec2-user 🟣


                        -------------

__/\\\\\\\\\\\\\____/\\\\____________/\\\\____/\\\\\\\\\_____
 _\/\\\/////////\\\_\/\\\\\\________/\\\\\\__/\\\///////\\\___
  _\/\\\_______\/\\\_\/\\\//\\\____/\\\//\\\_\///______\//\\\__
   _\/\\\\\\\\\\\\\/__\/\\\\///\\\/\\\/_\/\\\___________/\\\/___
    _\/\\\/////////____\/\\\__\///\\\/___\/\\\________/\\\//_____
     _\/\\\_____________\/\\\____\///_____\/\\\_____/\\\//________
      _\/\\\_____________\/\\\_____________\/\\\___/\\\/___________
       _\/\\\_____________\/\\\_____________\/\\\__/\\\\\\\\\\\\\\\_
        _\///______________\///______________\///__\///////////////__


                          Runtime Edition

        PM2 is a Production Process Manager for Node.js applications
                     with a built-in Load Balancer.

                Start and Daemonize any application:
                $ pm2 start app.js

                Load Balance 4 instances of api.js:
                $ pm2 start api.js -i 4

                Monitor in production:
                $ pm2 monitor

                Make pm2 auto-boot at server restart:
                $ pm2 startup

                To go further checkout:
                http://pm2.io/


                        -------------

[PM2] Init System found: systemd
Platform systemd
Template
[Unit]
Description=PM2 process manager
Documentation=https://pm2.keymetrics.io/
After=network.target

[Service]
Type=forking
User=ec2-user
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
Environment=PATH=/home/ec2-user/.local/bin:/home/ec2-user/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
Environment=PM2_HOME=/home/ec2-user/.pm2
PIDFile=/home/ec2-user/.pm2/pm2.pid
Restart=on-failure

ExecStart=/usr/local/share/.config/yarn/global/node_modules/pm2/bin/pm2 resurrect
ExecReload=/usr/local/share/.config/yarn/global/node_modules/pm2/bin/pm2 reload all
ExecStop=/usr/local/share/.config/yarn/global/node_modules/pm2/bin/pm2 kill

[Install]
WantedBy=multi-user.target

Target path
/etc/systemd/system/pm2-ec2-user.service
Command list
[ 'systemctl enable pm2-ec2-user' ]
[PM2] Writing init configuration in /etc/systemd/system/pm2-ec2-user.service
[PM2] Making script booting at startup...
[PM2] [-] Executing: systemctl enable pm2-ec2-user...
Created symlink /etc/systemd/system/multi-user.target.wants/pm2-ec2-user.service → /etc/systemd/system/pm2-ec2-user.service.
[PM2] [v] Command successfully executed.
+---------------------------------------+
[PM2] Freeze a process list on reboot via:
$ pm2 save

[PM2] Remove init script via:
$ pm2 unstartup systemd

⚠️ 위 단계에서 출력된 sudo env PATH=... 명령어를 그대로 복사-붙여넣기 하여 실행합니다. 이 과정이 pm2를 시스템 서비스로 정식 등록하는 핵심 단계입니다.

  1. pm2 save 🟣
[ec2-user@ip-172-31-33-23 server]$ pm2 save
[PM2] Saving current process list...
[PM2] Successfully saved in /home/ec2-user/.pm2/dump.pm2

⚠️ 현재 실행 중인 프로세스 목록(nest-server)을 저장합니다. 이렇게 해야 서버 재부팅 시 pm2가 시작되면서 저장된 목록을 읽어 nest-server를 자동으로 실행시켜 줍니다.

profile
Write a little every day, without hope, without despair ✍️

0개의 댓글