Skip to content

Instantly share code, notes, and snippets.

@zlrlo
Last active August 16, 2021 04:51
Show Gist options
  • Select an option

  • Save zlrlo/12ce3a4e64060fa914d7e85ba125537f to your computer and use it in GitHub Desktop.

Select an option

Save zlrlo/12ce3a4e64060fa914d7e85ba125537f to your computer and use it in GitHub Desktop.
nginx 사용법

nginx

동시접속 처리에 특화된 웹 서버 프로그램이다.

1. 설치(Ubuntu)

sudo apt-get update // 저장소 업데이트
sudo apt-get install -y nginx // nginx 설치
nginx -v // nginx 버전 확인

2. 설정

nginx에 웹팩 빌드 파일 연결
/etc/nginx/sites-available/default 파일 수정
server 블록에 경로 추가

root "/home/je/javascript-w5-accountbook/webapp/dist";
index "index.html";

3. 실행

$ nginx -t 
$ nginx // 실행
$ nginx -s reload 
$ nginx -s stop
  • 먼저 실행하고 reload 가능
  • -t 설정 파일이 문법적으로 올바른지 확인할 수 있다.
  • -s signal을 보내서 프로세스 제어
  • 기본 설정시 root로 실행 가능

4. 이슈

한글 깨짐 현상 문제 해결
/etc/nginx/nginx.conf 파일 http 블록에 charset 추가

http {
  ...
  charset utf-8;
  server { 
    charset utf-8; 
    }
}

unable to resolve host 에러 해결
/etc/hostname /etc/hosts 두 파일에 적혀있는 hostname 동일하게 수정
ex) zlrlo-test-server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment