2

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)

enter image description here

1
  • I had this issue and answered a similar question here: stackoverflow.com/a/71622285/514608 it only requires building caddy from source and downloading Go which is easy. Does that help?
    – Amon
    Nov 2, 2022 at 18:47

2 Answers 2

7

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
6
  • This didnt work. When i tried doing go/bin/xcaddy build -bash: go/bin/xcaddy: No such file or directory
    – Adam
    Nov 3, 2022 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. Nov 5, 2022 at 20:24
  • @Adam, A.H gave another answer which is fast and for me it worked. stackoverflow.com/a/74436450/514608 Nov 19, 2022 at 20:25
  • this is currently failing with the following:
    – Bob
    Dec 15, 2022 at 16:52
  • get"rsc.io/binaryregexp": found meta tag vcs.metaImport{Prefix:"rsc.io/binaryregexp", VCS:"git", RepoRoot:"github.com/rsc/binaryregexp"} at //rsc.io/binaryregexp?go-get=1 go: github.com/caddyserver/[email protected] requires golang.org/x/[email protected]: 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, 2022 at 16:53
6

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.

3
  • i think this will work, let me try... i'll be back
    – ndotie
    Nov 17, 2022 at 4:58
  • 1
    I get Requires: libc.so.6(GLIBC_2.34)(64bit). I have a libc.so.6 in /usr/lib64
    – user66081
    Dec 14, 2022 at 19:06
  • 2
    For 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 Mar 19 at 10:16

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.