TIL/DOCKER

[NGINX] EC2 Amazon Linux 에 NGINX 설치하기

아람2 2025. 1. 12. 09:01
반응형

Private Spring Server, Nest Server 에 접근할 수 있는 NGINX 를 설치하기로 했다 

 

우선 AWS 에 Public 으로 Instance 를 만들어준다 

키 페어를 생성하고, 기존 VPC 에 Public Region, Public IP 자동 할당, 

보안 그룹은 SSH, HTTP, HTTPS 로 설정했다 

그리고 탄력적 IP 도 연결해줬다 https://helloahram.tistory.com/204 

 

NGINX 를 설치하는 것은 매우 쉬웠다 

iTerms 를 통해 NGINX 에 접속해서, $ sudo yum install -y nginx 해주면 쫘르르르 설치가 된다 

$ sudo yum install -y nginx

 

설치가 되었는지 버전도 확인하고,

$ sudo nginx -v
nginx version: nginx/1.26.2

 

start 해 준 다음에

$ sudo systemctl start nginx

 

상태를 확인하면 Active: active (running) 을 확인할 수 있다 

$ systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
     Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; preset: disabled)
     Active: active (running) since Sat 2025-01-11 09:42:13 UTC; 10s ago
    Process: 27517 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
    Process: 27518 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
    Process: 27519 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
   Main PID: 27520 (nginx)
      Tasks: 2 (limit: 1111)
     Memory: 2.4M
        CPU: 38ms
     CGroup: /system.slice/nginx.service
             ├─27520 "nginx: master process /usr/sbin/nginx"
             └─27521 "nginx: worker process"

 

서버를 재부팅한 후에도 NGINX 를 자동으로 시작하게 설정해준다 

$ sudo systemctl enable nginx
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.

 

NGINX 설정 디렉토리 확인 

$ ls /etc/nginx
conf.d                fastcgi_params          mime.types          scgi_params           win-utf
default.d             fastcgi_params.default  mime.types.default  scgi_params.default
fastcgi.conf          koi-utf                 nginx.conf          uwsgi_params
fastcgi.conf.default  koi-win                 nginx.conf.default  uwsgi_params.default

 

NGINX 실행 파일 확인

$ which nginx
/usr/sbin/nginx

 

탄력적 IP 로 접속하여 확인하면, 짜잔 -           

반응형

'TIL > DOCKER' 카테고리의 다른 글

쿠버네티스와 도커, 관계 정리  (0) 2025.02.03
[AWS] 탄력적 IP 연결  (0) 2025.01.11
[Docker] Docker Image Build  (0) 2025.01.04
Docker Exited (0) 되는 문제 수정하기  (0) 2024.12.24
CI/CD via Jenkins #2  (0) 2024.12.23