基于 Caddy 展示个人静态博客
基于 hugo 生成的个人静态网站,有多种上线方式可以选择(参考 Host and deploy with hugo)。如果你和我一样,打算将个人博客部署在自己的 VPS 服务器上,那么 VPS 服务器需要运行 HTTP 服务,可以是 nginx,也可以是 caddy。这里我选择 caddy,因为它的文档完整,安装配置简单。 1. 安装 caddy caddy 支持多种安装方式,可以直接下载 caddy 二进制文件: from releases on GitHub (expand “Assets”) Refer to Verifying Asset Signatures for how to verify the asset signature from our download page by building from source (either with go or xcaddy) 也可以通过操作系统各自的包管理器进行安装,通常这种方式会为 caddy 自动创建用户和用户组,还会为 caddy 配置 systemd service。 生产环境下,十分建议将 caddy 配置为 systemd service。 Debian, Ubuntu, Raspbian # Debian, Ubuntu, Raspbian sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list chmod o+r /usr/share/keyrings/caddy-stable-archive-keyring.gpg chmod o+r /etc/apt/sources.list.d/caddy-stable.list sudo apt update sudo apt install caddy Installing this package automatically starts and runs Caddy as a systemd service named caddy. It also comes with an optional caddy-api service which is not enabled by default, but should be used if you primarily configure Caddy via its API instead of config files. ...