본문 바로가기

퍼블릭 클라우드

Amazon EC2 t4g.small 인스턴스에서 NGINX를 설치하는 방법

728x90

Amazon EC2 t4g.small 인스턴스에서 NGINX를 설치하는 방법

테스트 환경

  • 운영 체제 버전 정보 확인
$ lsb_release -d
Description:	Ubuntu 22.04.3 LTS
  • 운영 체제의 아키텍처 확인(Arm 기반 AWS Graviton 프로세서 사용)
$ uname -m
aarch64
  • 운영 체제의 비트 수
$ getconf LONG_BIT
64

NGINX 설치

필수 구성 요소 설치

sudo apt install curl gnupg2 ca-certificates lsb-release ubuntu-keyring

APT가 패키지의 신뢰성을 확인할 수 있도록 공식 NGINX 서명 키를 가져옵니다.

curl -fsSL https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
    | sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null

다운로드한 파일에 올바른 키가 포함되어 있는지 확인합니다.

gpg --dry-run --quiet --no-keyring --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg
$ gpg --dry-run --quiet --no-keyring --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg
pub   rsa2048 2011-08-19 [SC] [expires: 2024-06-14]
      573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
uid                      nginx signing key <signing-key@nginx.com>

fingerprint1

안정적인 NGINX 패키지를 위한 적절한 리포지토리를 설정하려면 다음과 같이 하세요.

echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
    | sudo tee /etc/apt/sources.list.d/nginx.list
728x90
sudo apt update

NGINX 패키지 설치

sudo apt install nginx
$ sudo apt install nginx
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  nginx
...
Preparing to unpack .../nginx_1.24.0-1~jammy_arm64.deb ...
----------------------------------------------------------------------

Thanks for using nginx!

Please find the official documentation for nginx here:
* https://nginx.org/en/docs/

Please subscribe to nginx-announce mailing list to get
the most important news about nginx:
* https://nginx.org/en/support.html

Commercial subscriptions for nginx are available on:
* https://nginx.com/products/

----------------------------------------------------------------------
...

NGINX 버전 정보 확인

$ nginx -v
nginx version: nginx/1.24.0

NGINX 서비스 활성화 및 시작

sudo systemctl --now enable nginx

NGINX 서비스 상태 확인

sudo systemctl status nginx
$ sudo systemctl status nginx
● nginx.service - nginx - high performance web server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2023-11-03 14:48:53 UTC; 2s ago
       Docs: https://nginx.org/en/docs/
    Process: 2835 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
   Main PID: 2836 (nginx)
      Tasks: 3 (limit: 2203)
     Memory: 2.5M
        CPU: 9ms
     CGroup: /system.slice/nginx.service
             ├─2836 "nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf"
             ├─2837 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
             └─2838 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""

Nov 03 14:48:53 ip-10-0-11-167 systemd[1]: Starting nginx - high performance web server...
Nov 03 14:48:53 ip-10-0-11-167 systemd[1]: Started nginx - high performance web server.

NGINX 설정 파일 확인

$ pwd
/etc/nginx
$ tree
.
├── conf.d
│   └── default.conf
├── fastcgi_params
├── mime.types
├── modules -> /usr/lib/nginx/modules
├── nginx.conf
├── scgi_params
└── uwsgi_params

2 directories, 6 files

 

참고URL

- nginx documentation : Ubuntu

 

728x90