GrepBoard/매뉴얼
47 편 ·

Nginx 설치와 서버 이름 설정

·Ubuntu 24.04.5 LTS · nginx 1.24.0·4 단계

Ubuntu 저장소에서 Nginx 를 설치하고 기본 사이트를 내 호스트 이름에 맞춘 뒤, 설정을 검사하고 연결을 끊지 않고 다시 읽게 합니다.

Ubuntu 24.04 저장소의 Nginx 를 설치하고, 기본 사이트가 내 호스트 이름으로 응답하게 합니다. 아래 호스트 이름은 www.example.com 으로 바꿔 적었습니다.

[1] 패키지를 설치합니다. 서비스 시작과 부팅 시 자동 시작은 패키지가 알아서 켭니다.

console
# apt-get install -y nginx# systemctl is-enabled nginxenabled# systemctl is-active nginxactive# nginx -vnginx version: nginx/1.24.0 (Ubuntu)

[2] 기본 사이트의 server_name _; 을 내 호스트 이름으로 바꿉니다. 파일에는 주석이 많으니 server_name 줄만 찾아 고칩니다.

/etc/nginx/sites-available/default
server {	listen 80 default_server;	listen [::]:80 default_server;	root /var/www/html;	index index.html index.htm index.nginx-debian.html;+	server_name www.example.com;

[3] 문법을 검사한 뒤 다시 읽게 합니다. reload 는 열린 연결을 끊지 않고, 검사에 실패하면 돌고 있는 설정은 그대로 남습니다.

console
# nginx -tnginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful# systemctl reload nginx

[4] 서버 자신에게 페이지를 요청해 봅니다. 호스트 이름은 Host 헤더로 흉내 냅니다.

console
$ curl -sI -H 'Host: www.example.com' http://localhost/HTTP/1.1 200 OKServer: nginx/1.24.0 (Ubuntu)Date: Mon, 19 Oct 2026 00:32:59 GMTContent-Type: text/htmlContent-Length: 615Last-Modified: Mon, 19 Oct 2026 00:32:47 GMTConnection: keep-aliveETag: "6ad5652f-267"Accept-Ranges: bytes

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

#nginx#ubuntu#web