I using AWS EC2 on Amazon Linux and when i trying to download the caddy (yum install caddy) i have the following error. (shown on screenshot)
-
I had this issue and answered a similar question here: https://stackoverflow.com/a/71622285/514608 it only requires building caddy from source and downloading Go which is easy. Does that help? – Amon Nov 02 '22 at 18:47
2 Answers
Edit Nov 19 2022 - A.H.'s answer worked for me, and is probably what you want. The solution I gave below works but is more complicated and takes 20 minutes; A.M.'s answer takes < 2 min to be up and running.
As of Oct 2022, you can build Caddy 2 without needing to know any golang.
Thanks to this answer: https://stackoverflow.com/a/71622285/514608. I give a bit more detail below, using a couple docs at caddyserver.org. I ran this on Amazon Linux 2 Kernel 5.10 AMI 2.0.20220912.1 x86_64 HVM gp2.
The steps I give use "xcaddy". The "go/bin/xcaddy build" command takes a long time, over 20 minutes for me. I did the plain-old-build, without xcaddy, a few days ago. Today, when I do it I am getting a security warning from go about bits not matching. As described in the docs, if you don't use "xcaddy" the resulting caddy executable's "version" subcommand doesn't work. With xcaddy it does.
Steps
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

- 1,905
- 18
- 26
-
This didnt work. When i tried doing go/bin/xcaddy build -bash: go/bin/xcaddy: No such file or directory – Adam Nov 03 '22 at 14:15
-
@Adam, does `go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest` complete without error? Try again, I just cut-and-paste the commands into a fresh ec2 without problem. – Levin Magruder Nov 05 '22 at 20:24
-
@Adam, A.H gave another answer which is fast and for me it worked. https://stackoverflow.com/a/74436450/514608 – Levin Magruder Nov 19 '22 at 20:25
-
-
get"rsc.io/binaryregexp": found meta tag vcs.metaImport{Prefix:"rsc.io/binaryregexp", VCS:"git", RepoRoot:"https://github.com/rsc/binaryregexp"} at //rsc.io/binaryregexp?go-get=1 go: github.com/caddyserver/certmagic@v0.17.2 requires golang.org/x/tools@v0.1.6-0.20210726203631-07bc1bf47fb2: invalid version: git fetch --unshallow -f origin in /home/ec2-user/go/pkg/mod/cache/vcs/7d9b3b49b55db5b40e68a94007f21a05905d3fda866f685220de88f9c9bad98a: exit status 128: fatal: Out of memory, malloc failed (tried to allocate 944857 bytes) fatal: fetch-pack: invalid index-pack output [FATAL] exit status 1 – Bob Dec 15 '22 at 16:53
-
@Bob I had that type of issue a few months ago and it went away few days later. – Levin Magruder Dec 16 '22 at 17:33
For me this recipe worked for Amazon Linux 2:
yum -y install yum-plugin-copr
yum -y copr enable @caddy/caddy epel-7-$(arch)
yum -y install caddy
Note the additional argument to copr enable
!
Here is a little more background for debugging the issue.

- 63,967
- 15
- 92
- 126
-
-
1I get Requires: libc.so.6(GLIBC_2.34)(64bit). I have a libc.so.6 in /usr/lib64 – user66081 Dec 14 '22 at 19:06
-
2For those who have tried the above commands and still getting errors, try to remove the yum-plugin-copr and delete the cache by this commands: sudo yum clean packages > sudo yum clean headers > sudo yum clean metadata > sudo yum clean all – Suraj Jorwekar Mar 19 '23 at 10:16