GrepBoard/매뉴얼
605 편 ·

nginx directive not terminated by ";" 해결

·시험 환경 nginx 1.30.6 (Docker) · 2026-11·시험 범위 ↓·7 단계

nginx directive is not terminated by ";" 는 세미콜론 없는 지시어 뒤에서 {가 나왔다는 뜻입니다. 이름이 찍힌 지시어의 줄 끝을 보고, 다른 문구와 가르는 법을 봅니다.

output
2026/11/02 22:14:55 [emerg] 12#12: directive "server_name" is not terminated by ";" in /etc/nginx/nginx.conf:6nginx: [emerg] directive "server_name" is not terminated by ";" in /etc/nginx/nginx.conf:6nginx: configuration file /etc/nginx/nginx.conf test failed

따옴표 안의 지시어(server_name)가 ; 로 끝나지 않았는데 그 뒤에서 { 가 나왔다는 뜻입니다. 이름이 찍힌 지시어의 줄 끝에 ; 를 붙이면 됩니다. 줄 번호는 ; 가 빠진 줄이 아니라 { 가 있는 줄입니다.

같은 세미콜론 누락도 그다음에 무엇이 오느냐에 따라 문구가 달라집니다. 이 글은 이 문구가 나오는 입력과 invalid number of arguments 나 unexpected end of file 이 나오는 입력을 재현으로 가릅니다.

[1] 오류에서 지시어 이름과 줄 번호를 읽습니다.

console
# nginx -t

directive "..." 의 따옴표 안이 ; 가 빠진 문장의 첫 단어이고, 끝의 숫자는 그 문장을 끊은 { 의 줄입니다. include 한 파일에서 났다면 경로가 그 파일을 가리킵니다.

[2] 이름이 찍힌 지시어를 설정에서 찾아 줄 끝을 봅니다. 아래에서 root 의 ; 가 빠졌고, 오류는 { 가 있는 6번째 줄을 가리켰습니다.

/etc/nginx/nginx.conf
        root /srv/app        location /api {            return 204;        }
output
nginx: [emerg] directive "root" is not terminated by ";" in /etc/nginx/nginx.conf:6

root /srv/app 줄(5번째) 끝에 ; 를 붙입니다. 사이에 빈 줄이나 주석이 있어도 같습니다.

[3] { 가 바로 붙은 경우도 같은 문구입니다. 블록을 받지 않는 지시어(listen, server_name, root 등)에 { 를 쓰면 나옵니다.

/etc/nginx/nginx.conf
        listen 8081 {
output
nginx: [emerg] directive "listen" is not terminated by ";" in /etc/nginx/nginx.conf:5

listen 8081; 로 고칩니다. [4] 문구가 다르면 ; 가 빠진 뒤에 온 것이 다른 겁니다. 같은 누락을 두고 뒤에 오는 것만 바꿔서 돌렸습니다.

; 가 빠진 문장 뒤에 온 것나온 오류줄
{ (location /api { 등)directive "root" is not terminated by ";"{ 의 줄
; 로 끝나는 다음 지시어, 인자가 정확히 1개인 지시어 (root)invalid number of arguments in "root" directive다음 줄
; 로 끝나는 다음 지시어, 인자를 여러 개 받는 지시어 (index)오류 없음-
}unexpected "}"} 의 줄
파일 끝unexpected end of file, expecting ";" or "}"파일 마지막 줄

[5] 인자를 여러 개 받는 지시어는 nginx -t 를 그냥 통과합니다. index 는 파일 이름을 여러 개 받는 지시어(index file ...;)라서, 다음 줄의 error_page 404 /404.html; 이 통째로 index 의 파일 이름 목록에 들어갔습니다.

/etc/nginx/nginx.conf
        index index.html        error_page 404 /404.html;
output
nginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful

검사가 통과해도 error_page 가 적용되지 않을 수 있으니, 지시어가 여러 개 연달아 나오는 곳은 줄마다 ; 로 끝나는지 직접 읽어 봅니다.

[6] 닫는 중괄호나 파일 끝에서 나오는 경우는 문구가 다릅니다.

/etc/nginx/nginx.conf
        location / {            root /srv/app        }
output
nginx: [emerg] unexpected "}" in /etc/nginx/nginx.conf:7

파일의 마지막 문장에서 빠지면 파일 끝에서 멈춥니다. 아래는 nginx.conf 가 worker_processes auto 로 끝난 경우이고, include 한 파일(proxy_set_header Host $host 로 끝나는 conf.d/headers.conf)에서도 같은 문구에 그 파일의 경로와 줄이 찍혔습니다.

output
nginx: [emerg] unexpected end of file, expecting ";" or "}" in /etc/nginx/nginx.conf:3

중괄호 쪽은 unexpected end of file, expecting "}" 를 봅니다.

[7] 반대 방향의 오류도 알아 둡니다. location 처럼 블록을 받는 지시어에 { 가 없으면 이름은 같아도 문구가 has no opening "{" 입니다.

output
nginx: [emerg] directive "location" has no opening "{" in /etc/nginx/nginx.conf:6

[8] 고친 뒤에는 검사하고, 통과하면 실행 중인 nginx 에 반영합니다. nginx -t 는 파일만 검사하므로 reload 하기 전까지 실행 중인 nginx 는 예전 설정으로 동작합니다.

console
# nginx -t
output
nginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful

통과하면 reload 합니다.

console
# nginx -s reload

nginx 공식 문서는 설정을 다시 읽히려면 마스터 프로세스에 HUP 신호를 보내라고 하며, nginx -s reload 가 그 방법입니다. 마스터는 먼저 문법을 검사하고 로그 파일과 새 listen 소켓을 열어 보는데, 이 단계가 실패하면 변경을 되돌리고 기존 설정으로 계속 동작한다고 문서에 적혀 있습니다. systemd 등 서비스 관리자로 돌리고 있다면 그쪽의 reload 명령을 쓰는데, 그 명령의 동작은 이 글에서 확인하지 않았습니다.

Nginx 로그를 브라우저에서 바로 분석 ↗ — 아무것도 올라가지 않습니다.

#nginx#nginx-t#semicolon#directive#config