Hugo 설치 · 14 min read · Oct 19, 2025

Rocky Linux 9에서 Nginx로 Hugo 사이트 생성기 설치하는 방법

정적 사이트는 정적 콘텐츠 또는 일반 HTML, JavaScript 또는 CSS 코드로 구성된 페이지로 만들어집니다. 콘텐츠는 동적으로 생성되지 않으며 데이터베이스나 서버 측 처리를 포함하지 않습니다. 이러한 사이트는 매우 빠르며 동적 코드나 SQL에 의존하는 공격에 면역입니다.

Hugo는 Go로 작성된 오픈 소스 정적 사이트 생성기입니다. Hugo는 마크다운 언어로 작성된 게시물을 HTML로 변환하여 콘텐츠를 생성합니다. Hugo는 생성한 사이트를 호스팅할 수 있는 내장 서버도 함께 제공합니다. 또한 Amazon S3, GitHub 페이지, Google Cloud, Netlify, Vercel 등에서 Hugo 웹사이트를 호스팅할 수 있습니다.

이 튜토리얼에서는 Rocky Linux 9에서 정적 웹사이트를 생성하기 위해 Hugo를 설치하는 방법을 살펴보겠습니다. 우리는 Nginx 서버를 사용하여 사이트를 호스팅하고 Let’s Encrypt SSL 인증서를 사용하여 설치를 안전하게 유지할 것입니다.

전제 조건

  • Rocky Linux 9에서 실행되는 서버.
  • sudo 권한이 있는 비루트 사용자.
  • 서버를 가리키는 완전한 도메인 이름(FQDN). 우리의 목적을 위해 hugo.example.com을 도메인 이름으로 사용할 것입니다.
  • 모든 것이 업데이트되었는지 확인하십시오. $ sudo dnf update
  • 기본 유틸리티 패키지를 설치합니다. 일부는 이미 설치되어 있을 수 있습니다. $ sudo dnf install wget curl nano unzip yum-utils tree -y

1단계 - 방화벽 구성

첫 번째 단계는 방화벽을 구성하는 것입니다. Rocky Linux는 Firewalld 방화벽을 사용합니다. 방화벽의 상태를 확인하십시오.

$ sudo firewall-cmd --state
running

방화벽은 다양한 영역과 함께 작동하며, 공용 영역이 우리가 사용할 기본 영역입니다. 방화벽에서 활성화된 모든 서비스와 포트를 나열합니다.

$ sudo firewall-cmd --permanent --list-services

다음과 같은 출력이 표시되어야 합니다.

cockpit dhcpv6-client ssh

Wiki.js는 작동하기 위해 HTTP 및 HTTPS 포트가 필요합니다. 이를 열어줍니다.

$ sudo firewall-cmd --add-service=http --permanent
$ sudo firewall-cmd --add-service=https --permanent

변경 사항을 적용하기 위해 방화벽을 다시 로드합니다.

$ sudo firewall-cmd --reload

2단계 - Nginx 설치

Rocky Linux 9는 이전 버전의 Nginx를 포함하고 있습니다. 최신 버전을 설치하기 위해 공식 Nginx 리포지토리를 다운로드해야 합니다.

공식 Nginx 리포지토리를 생성하기 위해 /etc/yum.repos.d/nginx.repo 파일을 생성하고 엽니다.

$ sudo nano /etc/yum.repos.d/nginx.repo

다음 코드를 붙여넣습니다.

[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

파일을 저장하려면 Ctrl + X를 누르고 프롬프트가 나타나면 Y를 입력합니다.

Nginx 서버를 설치합니다.

$ sudo dnf install nginx -y

설치를 확인합니다.

$ nginx -v
nginx version: nginx/1.24.0

Nginx 서버를 활성화하고 시작합니다.

$ sudo systemctl enable nginx --now

서버의 상태를 확인합니다.

$ sudo systemctl status nginx
? nginx.service - nginx - high performance web server
     Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: disabled)
     Active: active (running) since Mon 2023-10-30 08:24:05 UTC; 7s ago
       Docs: http://nginx.org/en/docs/
    Process: 4265 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
   Main PID: 4266 (nginx)
      Tasks: 2 (limit: 4402)
     Memory: 1.9M
        CPU: 7ms
     CGroup: /system.slice/nginx.service
             ??4266 "nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf"
             ??4267 "nginx: worker process"

Oct 30 08:24:05 hugo.example.com systemd[1]: Starting nginx - high performance web server...

3단계 - Git 설치

Hugo는 작동하기 위해 Git이 필요합니다. Git을 설치하려면 다음 명령을 실행하십시오.

$ sudo dnf install git -y

Git 설치를 확인합니다.

$ git --version
git version 2.39.3

4단계 - Hugo 설치

Hugo는 Go 언어로 구축되었기 때문에 설치가 매우 쉽습니다. 의존성이 필요하지 않으며 독립 실행형으로 실행할 수 있습니다.

Hugo를 다운로드합니다. 이 튜토리얼에서는 Hugo의 확장 버전을 설치할 것입니다. 확장 버전은 이미지를 처리할 때 Webp 형식으로 인코딩할 수 있습니다. 이는 Hugo가 이미지를 즉시 변환하고 크기를 줄이기를 원할 때 유용합니다. 확장 버전에는 SASS 컴파일러도 포함되어 있어 특정 경우에 유용할 수 있습니다.

Hugo를 위한 디렉토리를 생성합니다.

$ sudo mkdir /var/www/html/hugo -p

새로 생성된 디렉토리로 전환합니다.

$ cd /var/www/html/hugo

GitHub 릴리스 페이지에서 Hugo를 다운로드합니다. 이 튜토리얼을 작성하는 시점에서 v0.119.0이 최신 버전입니다. 우리는 이 버전을 다운로드할 것입니다.

$ sudo wget https://github.com/gohugoio/hugo/releases/download/v0.119.0/hugo_extended_0.119.0_linux-amd64.tar.gz

아카이브에서 파일을 추출합니다.

$ sudo tar -xzf hugo_extended_0.119.0_linux-amd64.tar.gz

디렉토리에서 다음 세 개의 파일을 볼 수 있습니다.

$ ls
hugo  hugo_extended_0.119.0_linux-amd64.tar.gz  LICENSE  README.md

hugo 바이너리를 /usr/bin 디렉토리로 이동합니다.

$ sudo mv hugo /usr/bin/hugo

파일은 이미 실행 권한이 설정되어 있으므로 추가로 설정할 필요가 없습니다.

설치를 확인합니다.

$ hugo version
hugo v0.119.0-b84644c008e0dc2c4b67bd69cccf87a41a03937e+extended linux/amd64 BuildDate=2023-09-24T15:20:17Z VendorInfo=gohugoio

--help 플래그를 사용하여 사용 가능한 모든 옵션을 확인할 수도 있습니다.

$ hugo --help

다음과 같은 출력이 표시됩니다.

hugo is the main command, used to build your Hugo site.

Hugo is a Fast and Flexible Static Site Generator
built with love by spf13 and friends in Go.

Complete documentation is available at https://gohugo.io/.

Usage:
  hugo [flags]
  hugo [command]

Available Commands:
  completion  Generate the autocompletion script for the specified shell
  config      Print the site configuration
  convert     Convert your content to different formats
  deploy      Deploy your site to a Cloud provider.
  env         Print Hugo version and environment info
  gen         A collection of several useful generators.
  help        Help about any command
  import      Import your site from others.
  list        Listing out various types of content
  mod         Various Hugo Modules helpers.
  new         Create new content for your site
  server      A high performance webserver
  version     Print Hugo version and environment info

Flags:
  -b, --baseURL string             hostname (and path) to the root, e.g. https://spf13.com/
  -D, --buildDrafts                include content marked as draft
  -E, --buildExpired               include expired content
  -F, --buildFuture                include content with publishdate in the future
      --cacheDir string            filesystem path to cache directory
      --cleanDestinationDir        remove files from destination not found in static directories
      --clock string               set the clock used by Hugo, e.g. --clock 2021-11-06T22:30:00.00+09:00
      --config string              config file (default is hugo.yaml|json|toml)
      --configDir string           config dir (default "config")
  -c, --contentDir string          filesystem path to content directory
      --debug                      debug output
  -d, --destination string         filesystem path to write files to
      --disableKinds strings       disable different kind of pages (home, RSS etc.)
      --enableGitInfo              add Git revision, date, author, and CODEOWNERS info to the pages
  -e, --environment string         build environment
      --forceSyncStatic            copy all files when static is changed.
      --gc                         enable to run some cleanup tasks (remove unused cache files) after the build
  -h, --help                       help for hugo
      --ignoreCache                ignores the cache directory
      --ignoreVendorPaths string   ignores any _vendor for module paths matching the given Glob pattern
  -l, --layoutDir string           filesystem path to layout directory
      --logLevel string            log level (debug|info|warn|error)
      --minify                     minify any supported output format (HTML, XML etc.)
      --noBuildLock                don't create .hugo_build.lock file
      --noChmod                    don't sync permission mode of files
      --noTimes                    don't sync modification time of files
      --panicOnWarning             panic on first WARNING log
      --poll string                set this to a poll interval, e.g --poll 700ms, to use a poll based approach to watch for file system changes
      --printI18nWarnings          print missing translations
      --printMemoryUsage           print memory usage to screen at intervals
      --printPathWarnings          print warnings on duplicate target paths etc.
      --printUnusedTemplates       print warnings on unused templates.
      --quiet                      build in quiet mode
      --renderToMemory             render to memory (only useful for benchmark testing)
  -s, --source string              filesystem path to read files relative from
      --templateMetrics            display metrics about template executions
      --templateMetricsHints       calculate some improvement hints when combined with --templateMetrics
  -t, --theme strings              themes to use (located in /themes/THEMENAME/)
      --themesDir string           filesystem path to themes directory
      --trace file                 write trace to file (not useful in general)
  -v, --verbose                    verbose output
  -w, --watch                      watch filesystem for changes and recreate as needed

Use "hugo [command] --help" for more information about a command.

폴더에 더 이상 필요하지 않은 모든 나머지 파일을 삭제합니다.

$ sudo rm -rf *.*

5단계 - 새로운 Hugo 사이트 만들기

다음 명령을 실행하여 새로운 Hugo 웹사이트를 만듭니다.

$ sudo hugo new site howtoforge

다음과 같은 출력이 표시됩니다.

축하합니다! 새로운 Hugo 사이트가 /home/navjot/hugo/howtoforge에 생성되었습니다.

몇 가지 더 단계가 필요합니다...

1. 현재 디렉토리를 /home/navjot/hugo/howtoforge로 변경하십시오.
2. 테마를 생성하거나 설치하십시오:
   - "hugo new theme " 명령으로 새로운 테마를 생성하십시오.
   - https://themes.gohugo.io/에서 테마를 설치하십시오.
3. "theme" 속성을 테마 이름으로 설정하여 hugo.toml을 편집하십시오.
4. "hugo new content /." 명령으로 새로운 콘텐츠를 생성하십시오.
5. "hugo server --buildDrafts" 명령으로 내장 웹 서버를 시작하십시오.

자세한 내용은 https://gohugo.io/를 참조하십시오.

tree 명령을 실행하여 사이트 구조를 확인합니다.

$ tree howtoforge/

다음과 같은 출력이 표시됩니다.

howtoforge/
??? archetypes
?   ??? default.md
??? assets
??? content
??? data
??? hugo.toml
??? i18n
??? layouts
??? static
??? themes

8 directories, 2 files

Hugo 디렉토리로 전환합니다.

$ cd howtoforge

6단계 - Hugo 테마 설치

다음 단계는 Hugo 테마를 설치하는 것입니다. 두 가지 방법이 있으며 둘 다 Git이 필요합니다. 첫 번째 방법은 간단하게 테마의 GitHub 리포지토리를 클론하는 것입니다. 이는 대부분의 경우 유용하며 가장 쉬운 방법입니다. 이 방법을 통해 업데이트하는 것도 쉽지만, 불필요한 많은 파일을 다운로드해야 할 수도 있습니다. 특히 유료 테마는 GitHub 리포지토리가 없어서 수동으로 압축 아카이브를 추출하고 수동으로 테마를 업데이트해야 할 수 있습니다. 세 번째 방법은 테마를 Git 서브모듈로 가져오는 것입니다. 이 방법은 Hugo 디렉토리를 Git 리포지토리로 초기화해야 합니다. 이는 추천되는 방법이며, GitHub, Netlify 또는 기타 호스팅 서비스에 사이트를 배포하려는 경우 유용합니다. Hugo 사이트를 GitHub에 푸시하면 자동 백업도 보장됩니다.

세 가지 방법을 모두 다룰 것입니다. Hugo Go 모듈을 사용하여 Hugo 테마를 설치하는 또 다른 방법이 있습니다. 이 방법은 테마가 Hugo 모듈로 제공되는 경우에만 작동합니다. 그러나 이 기사의 범위를 벗어나므로 다루지 않을 것입니다.

방법 1 - Hugo 테마 클론하기

이것은 Hugo 테마를 설치하는 가장 일반적으로 사용되는 방법입니다. 이 튜토리얼에서는 Paper 테마를 설치할 것입니다. Hugo 디렉토리로 전환합니다.

$ cd /var/www/html/hugo/howtoforge

다음 명령을 실행하여 테마의 GitHub 리포지토리를 클론합니다. --depth=1 플래그는 최신 커밋만 가져옵니다.

$ sudo git clone https://github.com/nanxiaobei/hugo-paper themes/Paper --depth=1

이 방법으로 다운로드한 테마를 업데이트하려면 다음 명령을 실행합니다.

$ cd ~/hugo/howtoforge/themes/Paper
$ sudo git pull

방법 2 - 압축 아카이브에서 테마 설치하기

이것은 가장 쉬운 방법입니다. 테마 파일의 아카이브를 가져옵니다. Paper 테마는 릴리스 섹션이 없으므로 특정 버전을 다운로드할 수 없습니다. 따라서 GitHub 마스터 아카이브를 다운로드할 것입니다. GitHub 리포지토리 페이지에서 링크를 가져올 수 있습니다.

$ cd ~
$ wget https://github.com/nanxiaobei/hugo-paper/archive/refs/heads/main.zip

테마 디렉토리에 아카이브를 추출합니다. -q 플래그는 출력을 억제하고 -d 플래그는 출력 디렉토리를 지정합니다.

$  sudo unzip -q main.zip -d /var/www/html/hugo/howtoforge/themes/

테마를 업데이트하려면 최신 아카이브를 다운로드하고 다시 추출해야 합니다. 변경한 모든 파일의 백업을 반드시 만들어 두십시오.

하단 두 방법은 Hugo 사이트가 Git 프로젝트로 호스팅되는 경우에만 작동합니다. 그렇지 않으면 다음 방법을 사용할 필요가 없습니다.

방법 3 - Git 서브모듈로 테마 설치하기

Hugo 폴더로 전환합니다.

$ cd /var/www/html/hugo/howtoforge

Hugo 폴더를 Git 리포지토리로 초기화합니다. 이는 중요한 단계입니다. 이를 통해 나중에 GitHub에 Hugo 사이트를 푸시할 수 있습니다.

$ sudo git init

다음 명령을 실행하여 테마를 Git 서브모듈로 추가합니다.

$ sudo git submodule add https://github.com/nanxiaobei/hugo-paper themes/paper

서브모듈로 추가된 테마를 업데이트하려면 Hugo 폴더에서 다음 명령을 실행합니다.

$ sudo git submodule update --remote --merge

Hugo 구성

선택한 방법으로 테마를 설치한 후, Hugo의 루트 디렉토리에 있는 hugo.toml 파일을 엽니다. Hugo v0.110.0부터 기본 구성 파일 이름은 hugo.toml입니다. 이전 버전의 Hugo를 사용하는 경우 Hugo 디렉토리에서 config.toml 파일을 찾을 수 있습니다.

$ sudo nano hugo.toml

파일에 다음 줄을 추가합니다. 값은 테마의 디렉토리와 일치해야 합니다. Paper 테마의 경우 아카이브 설치를 사용한 경우 hugo-paper-theme 디렉토리가 되고, 위의 Git 클론 또는 서브모듈 방법을 사용한 경우 Paper가 됩니다.

theme = 'hugo-paper-main'

또한 baseURL 변수의 값을 사이트의 도메인 이름으로 변경하고, 웹사이트의 title을 변경합니다.

구성 파일은 다음과 같아야 합니다.

baseURL = 'https://hugo.example.com/'
languageCode = 'en-us'
title = 'Howtoforge Hugo Demo'
theme = 'hugo-paper-main'

작업이 끝나면 Ctrl + X를 눌러 파일을 저장하고 프롬프트가 나타나면 Y를 입력합니다.

7단계 - 게시물 및 페이지 만들기

새 게시물을 만들려면 다음 명령을 실행합니다.

$ sudo hugo new post/first-post.md

이렇게 하면 content/post 폴더에 제목이 First Post인 새로운 마크다운 파일 first-post.md가 생성됩니다. 파일을 좋아하는 편집기로 열고 세부 정보를 편집하고 첫 번째 게시물에 대한 내용을 작성하십시오.

+++
title = 'First Post'
date = 2023-10-30T03:32:38Z
draft = true
+++
## 소개

이것은 굵게 표시된 텍스트이며, 이것은 *강조된* 텍스트입니다.

[Howtoforge](https://www.howtoforge.com) 웹사이트를 방문하세요!

게시물 작성을 마친 후 draft = true를 제거합니다. Ctrl + X를 눌러 파일을 저장하고 프롬프트가 나타나면 Y를 입력합니다.

새 페이지를 만들려면 다음 명령을 실행합니다.

$ sudo hugo new about.md

이렇게 하면 content 폴더에 About이라는 제목의 새 페이지가 생성됩니다. 이를 열고 게시물과 같은 방식으로 편집합니다.

테마 구성

게시하기 전에 메뉴 바를 표시하기 위해 테마에 몇 가지 변경을 해야 합니다. 이러한 변경은 테마의 구성 파일이 아니라 Hugo의 구성 파일에서 이루어집니다.

Hugo 디렉토리로 전환합니다.

$ cd /var/www/html/hugo/howtoforge

hugo.toml 파일을 편집하기 위해 엽니다.

$ sudo nano hugo.toml

하단에 다음 코드를 붙여넣습니다.

author = "Navjot Singh"
copyright = "Copyright © 2023, Navjot Singh; all rights reserved."
paginate = 3
enableInlineShortcodes = true
# 필요한 경우 원시 HTML을 렌더링하기 위해 (예: , , , )
[markup]
  [markup.goldmark]
    [markup.goldmark.renderer]
      unsafe = true

[menu]
  [[menu.main]]
    identifier = "about"
    name = "About"
    url = "/about/"
    weight = 10

[taxonomies]
category = "categories"
tag = "tags"
series = "series"

Ctrl + X를 눌러 파일을 저장하고 프롬프트가 나타나면 Y를 입력합니다.

이것은 사이트를 기능적으로 만들기 위한 몇 가지 기본 설정입니다. 여기서는 페이지당 3개의 게시물을 표시하고, About 페이지를 메뉴 항목으로 표시하며, 카테고리, 태그 및 게시물 시리즈를 설정했습니다. 또한 Hugo의 인라인 숏코드를 활성화하고 Goldmark Markdown 렌더에 대해 원시 HTML을 활성화했습니다. 게시물에 원시 HTML을 포함하고 싶지 않다면 이를 비활성화할 수 있습니다.

8단계 - Hugo 사이트 게시

사이트를 빌드하고 게시하려면 다음 명령을 실행하십시오.

$ sudo hugo

비슷한 출력이 표시됩니다.

사이트 빌드 시작 …
hugo v0.119.0-b84644c008e0dc2c4b67bd69cccf87a41a03937e+extended linux/amd64 BuildDate=2023-09-24T15:20:17Z VendorInfo=gohugoio


                   | EN
-------------------+-----
  Pages            |  7
  Paginator pages  |  0
  Non-page files   |  0
  Static files     | 11
  Processed images |  0
  Aliases          |  3
  Sitemaps         |  1
  Cleaned          |  0

총 46 ms 소요

이렇게 하면 public 폴더에 정적 Hugo 웹사이트가 생성되고 게시됩니다. 이러한 파일은 사이트가 작동하도록 Nginx 구성에서 지정해야 합니다. 변경 사항을 적용한 후 명령을 다시 실행하면 웹사이트가 즉시 업데이트됩니다.

9단계 - SSL 설치

진행하기 전에 Certbot 도구를 설치하고 도메인에 대한 SSL 인증서를 설치해야 합니다.

Certbot을 설치하기 위해 Snapd 패키지 설치 관리자를 사용할 것입니다. Snapd는 항상 Certbot의 최신 안정 버전을 제공하므로 이를 사용하는 것이 좋습니다.

Snapd 도구는 Epel 리포지토리가 필요합니다.

$ sudo dnf install epel-release -y

Snapd를 사용하여 Certbot을 설치합니다. Snapd를 설치합니다.

$ sudo dnf install snapd -y

Snap 서비스를 활성화하고 시작합니다.

$ sudo systemctl enable snapd.socket --now

Snapd가 작동하도록 필요한 링크를 생성합니다.

$ sudo ln -s /var/lib/snapd/snap /snap
$ echo 'export PATH=$PATH:/var/lib/snapd/snap/bin' | sudo tee -a /etc/profile.d/snapd.sh

Snapd 버전이 최신인지 확인합니다. 다음 명령을 실행하기 전에 몇 초 기다리십시오.

$ sudo snap install core
$ sudo snap refresh core

Certbot을 설치합니다.

$ sudo snap install --classic certbot

다음 명령을 사용하여 /usr/bin 디렉토리에 대한 심볼릭 링크를 생성하여 Certbot 명령을 실행할 수 있도록 합니다.

$ sudo ln -s /snap/bin/certbot /usr/bin/certbot

설치를 확인합니다.

$ certbot --version
certbot 2.7.3

SSL 인증서를 생성합니다.

$ sudo certbot certonly --nginx --agree-tos --no-eff-email --staple-ocsp --preferred-challenges http -m [email protected] -d hugo.example.com

위 명령은 서버의 /etc/letsencrypt/live/hugo.example.com 디렉토리에 인증서를 다운로드합니다.

Diffie-Hellman 그룹 인증서를 생성합니다.

$ sudo openssl dhparam -dsaparam -out /etc/ssl/certs/dhparam.pem 4096

Certbot 갱신 스케줄러 서비스를 확인합니다.

$ sudo systemctl list-timers

snap.certbot.renew.service가 실행될 서비스 중 하나로 표시됩니다.

NEXT                        LEFT          LAST                        PASSED    UNIT                         ACTIVATES
Wed 2023-10-29 10:00:17 UTC 57min left    Wed 2023-10-18 08:49:39 UTC 12min ago dnf-makecache.timer          dnf-makecache.service
Wed 2023-10-29 12:18:00 UTC 3h 15min left -                           -         snap.certbot.renew.timer     snap.certbot.renew.service
Thu 2023-10-30 00:00:00 UTC 14h left      Wed 2023-10-18 08:10:08 UTC 52min ago logrotate.timer              logrotate.service

SSL 갱신이 잘 작동하는지 확인하기 위해 프로세스를 드라이 런합니다.

$ sudo certbot renew --dry-run

오류가 없으면 모든 준비가 완료된 것입니다. 인증서는 자동으로 갱신됩니다.

10단계 - Nginx 구성

/etc/nginx/conf.d/hugo.conf 파일을 생성하고 열어 편집합니다.

$ sudo nano /etc/nginx/conf.d/hugo.conf

hugo.conf 파일에 다음 코드를 붙여넣습니다. hugo.example.com의 모든 인스턴스를 도메인으로 교체하십시오.

## HTTPS 강제 적용
server {
  listen 80;
  listen [::]:80;
  server_name hugo.example.com;
  return 301 https://$server_name$request_uri;
}

server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  server_name hugo.example.com;

  root /home/navjot/hugo/howtoforge/public;
  index index.html
  
  access_log /var/log/nginx/hugo.access.log;
  error_log /var/log/nginx/hugo.error.log;
  client_max_body_size 20m;
  gzip on;

  http2_push_preload on; # HTTP/2 서버 푸시 활성화

  ssl_certificate     /etc/letsencrypt/live/hugo.example.com/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/hugo.example.com/privkey.pem;
  ssl_trusted_certificate /etc/letsencrypt/live/hugo.example.com/chain.pem;
  ssl_session_timeout 1d;

  # TLS 버전 활성화 (TLSv1.3는 다가오는 HTTP/3 QUIC에 필요).
  ssl_protocols TLSv1.2 TLSv1.3;

  # TLSv1.3의 0-RTT 활성화. 리버스 프록시를 사용할 때 재전송 공격을 방지하기 위해 $ssl_early_data를 사용하십시오.
  #
  # @see: https://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_early_data
  ssl_early_data on;

  ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384';
  ssl_prefer_server_ciphers on;
  ssl_ecdh_curve X25519:prime256v1:secp384r1:secp521r1;
  ssl_session_cache shared:SSL:50m;
  ssl_session_tickets off;

  # OCSP 스테이플링 ---
  # ssl_certificate에서 URL의 OCSP 레코드를 가져와 캐시합니다.
  ssl_stapling on;
  ssl_stapling_verify on;
  ssl_dhparam /etc/ssl/certs/dhparam.pem;

  add_header X-Early-Data $tls1_3_early_data;
  
  location / {
      try_files $uri $uri/ =404;
  }
  
  # 미디어
  location ~* \\.jpg|jpeg|gif|png|ico|cur|gz|svg|mp4|ogg|ogv|webm|htc$ {
      expires 30d;
  }

  # CSS 및 Js
  location ~* \\.css|js$ {
      expires 7d;
  }
}

# 이 블록은 TLS v1.3 디버깅에 유용합니다. 원하시면 이를 제거하고 NGINX에서 직접 노출된 $ssl_early_data 변수를 사용하십시오.
map $ssl_early_data $tls1_3_early_data {
  "~." $ssl_early_data;
  default "";
}

위 구성은 모든 HTTP 요청을 HTTPS로 리디렉션하고 Hugo 서비스가 도메인을 통해 제공되도록 프록시 역할을 합니다.

Ctrl + X를 눌러 파일을 저장하고 프롬프트가 나타나면 Y를 입력합니다.

/etc/nginx/nginx.conf 파일을 열어 편집합니다.

$ sudo nano /etc/nginx/nginx.conf

include /etc/nginx/conf.d/*.conf; 줄 앞에 다음 줄을 추가합니다.

server_names_hash_bucket_size  64;

Ctrl + X를 눌러 파일을 저장하고 프롬프트가 나타나면 Y를 입력합니다.

Nginx 구성을 확인합니다.

$ sudo nginx -t

오류가 없으면 준비가 완료된 것입니다. Nginx 서버를 다시 로드합니다.

$ sudo systemctl reload nginx

11단계 - SELinux 구성

OpenEMR에 대한 파일 보안 컨텍스트를 변경합니다.

$ sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/hugo/howtoforge/public(/.*)?"

정책을 적용합니다.

$ sudo restorecon -Rv /var/www/html/hugo/howtoforge/public/

Nginx가 네트워크에 연결할 수 있도록 허용합니다.

$ sudo setsebool -P httpd_can_network_connect 1

12단계 - 사이트 실행

이제 웹 브라우저에서 https://hugo.example.com을 열어 설치를 확인할 수 있습니다. 성공적인 설치를 나타내는 다음 페이지가 표시됩니다.

Hugo 홈페이지

13단계 - Hugo 업데이트

Hugo 업데이트는 매우 간단합니다. Hugo의 GitHub 페이지에서 최신 릴리스를 다운로드합니다.

$ cd /var/www/html/hugo
$ sudo wget https://github.com/gohugoio/hugo/releases/download/v0.119.0/hugo_extended_0.119.0_linux-amd64.tar.gz

아카이브를 추출합니다.

$ sudo tar -xzf hugo_extended_0.119.0_linux-amd64.tar.gz

최신 버전으로 Hugo 바이너리를 교체합니다. -f 플래그는 프롬프트 없이 바이너리를 덮어씁니다. 덮어쓰기에 대한 프롬프트를 원하면 대신 -i 플래그를 사용할 수 있습니다.

$ sudo mv -f hugo /usr/bin/hugo

그게 전부입니다. Hugo 업데이트는 바이너리를 교체하는 것만큼 간단합니다.

14단계 - Hugo 백업 및 복원

백업을 하려면 전체 Hugo 폴더의 아카이브를 생성합니다.

$ cd /var/www/html/hugo
$ sudo tar -czvf howtoforge.tar.gz howtoforge/

새 서버에서 복원하려면 아카이브를 추출하고 바이너리를 설치하면 됩니다.

$ cd /var/www/html/hugo
$ sudo tar -xzf howtoforge.tar.gz

결론

이것으로 Rocky Linux 9 서버에서 Nginx를 사용하여 Hugo 정적 사이트 생성기를 설정하는 방법에 대한 튜토리얼이 끝났습니다. 질문이나 피드백이 있으면 아래 댓글로 공유해 주세요.

Share: X/Twitter LinkedIn

새 게시물을 받은 편지함에서 받기

스팸은 없습니다. 언제든지 구독 해지 가능합니다.