无法在 yum 上下载 caddy 包

Qua*_*tz_ 4 yum amazon-ec2 amazon-web-services caddy

我在 Amazon Linux 上使用 AWS EC2,当我尝试下载 caddy (yum install caddy) 时,出现以下错误。(如屏幕截图所示)

在此输入图像描述

A.H*_*.H. 9

对我来说,这个食谱适用于 Amazon Linux 2:

yum -y install yum-plugin-copr
yum -y copr enable @caddy/caddy epel-7-$(arch)
yum -y install caddy
Run Code Online (Sandbox Code Playgroud)

copr enable请注意!的附加参数

以下是调试该问题的更多背景信息。

  • 对于那些已尝试上述命令但仍然出现错误的人,请尝试通过以下命令删除 yum-plugin-copr 并删除缓存: sudo yum clean packages > sudo yum clean headers > sudo yum cleanmetadata > sudo yum clean all (2认同)

Lev*_*der 7

编辑 2022 年 11 月 19 日 - AH 的答案 对我有用,可能就是你想要的。 我下面给出的解决方案可行,但更复杂,需要 20 分钟;AM 的回答只需不到 2 分钟即可启动并运行。


截至 2022 年 10 月,您无需了解任何 golang 即可构建 Caddy 2。

感谢这个答案:/sf/answers/5013559981/。下面我使用 caddyserver.org 上的几个文档提供了更多详细信息。我在 Amazon Linux 2 Kernel 5.10 AMI 2.0.20220912.1 x86_64 HVM gp2 上运行此程序。

我给出的步骤使用“xcaddy”。“go/bin/xcaddy build”命令需要很长时间,对我来说超过 20 分钟。几天前,我在没有 xcaddy 的情况下做了普通的旧构建。今天,当我这样做时,我收到了有关位不匹配的安全警告。如文档中所述,如果您不使用“xcaddy”,则生成的 caddy 可执行文件的“version”子命令将不起作用。有了 xcaddy 就可以了。

脚步


sudo yum install go -y

go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest

go/bin/xcaddy build
./caddy version
sudo cp caddy /usr/bin
# /usr/bin is the path used in example systemd unit files from
# caddy server.org, so if you don't use this path, you'd edit those
caddy version

#  following: see https://caddyserver.com/docs/running

sudo groupadd --system caddy
sudo useradd --system \
    --gid caddy \
    --create-home \
    --home-dir /var/lib/caddy \
    --shell /usr/sbin/nologin \
    --comment "Caddy web server" \
    caddy
#  not shown but required: you create a file named  /etc/systemd/system/caddy.service
#  as per docs/running link above, use one of the two unit files
#  as a templat.  After which, if you are using a Caddyfile:

sudo mkdir /etc/caddy

#  And then create a Caddyfile in there at /etc/caddy/Caddyfile

sudo systemctl daemon-reload
sudo systemctl enable --now caddy
systemctl status -l caddy
Run Code Online (Sandbox Code Playgroud)