Skip to content
套用主题

欢迎来到我的网站

官网文档

安装

for Linux - Debian

Terminal window
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
sudo apt update
sudo apt install caddy

快速部署

有2种方式: API 和 Caddyfile (我选择Caddyfile)

  1. 任意文件夹创建文件Caddyfile ,无需后缀名

  2. 打开,输入内容

    localhost
    respond "Hello, world!"
    localhost:8080
    respond "hello, yyc!"
  3. 开启caddy服务

    Terminal window
    caddy start

    如果遇到端口占用,通过lsof -i:端口号 查看

  4. 在命令行中输入 : curl https://localhost (caddy默认是https), 会返回hello, world! 成功

  5. 如果期间修改了Caddylife内容,无需停止服务,只需要重启 csddy reload

  6. 关闭服务 caddy stop


Caddyfile 内容:

我已经设置成功了我的网站,使用https 需要ssl证书, 流程:

  1. 获得证书 ,我使用zerossl ( 用户名 qq邮箱 密码 2011 )

  2. 获取认证key后,写入caddyfile内:

    yyclovezl.cn {
    root * /home/astro-starlight/dist
    encode zstd gzip
    file_server browse
    tls {
    ca https://acme.zerossl.com/v2/DV90
    eab key1 key2 // 密钥在我云盘上 或者登陆zerossl官网获取
    }
    }