Unable to install Caddy via binaries

1. The problem I’m having:

I’m attempting to install the Caddy Static binaries listed at Install — Caddy Documentation. I downloaded the Cloudflare binary and am currently trying to install Caddy as a system service. I renamed the file to caddy as listed in the Manual Installation section in the docs and then ran the command sudo mv caddy /usr/bin/ which was successful. However, when I try running caddy version, I get the error: bash: /usr/bin/caddy: Permission denied and cannot sudo as caddy is not a command.

2. Error messages and/or full log output:

`bash: /usr/bin/caddy: Permission denied`

3. Caddy version:

Unable to run caddy version but attempting to install caddy server v2.

4. How I installed and ran Caddy:

a. System environment:

OS: Ubuntu 22.04 Jammy
Architecture: AMDx64

b. Command:

sudo mv caddy /usr/bin
caddy version

c. Service/unit/compose file:

d. My complete Caddy config:

5. Links to relevant resources:

Make sure to give executable permission to the binary if you copy it manually. Run sudo chmod +x /usr/bin/caddy.

Since you’re on ubuntu though, I strongly recommend installing using the apt repo, which does this for you:

Thanks that worked. However, when I try the command sudo systemctl enable --now caddy, I get the error down below.

Here is what shows up when I run systemctl status caddy.service

× caddy.service - Caddy
     Loaded: loaded (/etc/systemd/system/caddy.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Tue 2023-05-16 19:51:27 CDT; 15s ago
       Docs: https://caddyserver.com/docs/
    Process: 17590 ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile (code=exited, status=1/FAILURE)
   Main PID: 17590 (code=exited, status=1/FAILURE)
        CPU: 30ms

May 16 19:51:27 user-NUC11TNHi5 caddy[17590]: HOME=/var/lib/caddy
May 16 19:51:27 user-NUC11TNHi5 caddy[17590]: LOGNAME=caddy
May 16 19:51:27 user-NUC11TNHi5 caddy[17590]: USER=caddy
May 16 19:51:27 user-NUC11TNHi5 caddy[17590]: INVOCATION_ID=f96acb2b2d84497a86c3f468d1cf005c
May 16 19:51:27 user-NUC11TNHi5 caddy[17590]: JOURNAL_STREAM=8:243935
May 16 19:51:27 user-NUC11TNHi5 caddy[17590]: SYSTEMD_EXEC_PID=17590
May 16 19:51:27 user-NUC11TNHi5 caddy[17590]: Error: reading config file: open /etc/caddy/Caddyfile: no such file or directory
May 16 19:51:27 user-NUC11TNHi5 systemd[1]: caddy.service: Main process exited, code=exited, status=1/FAILURE
May 16 19:51:27 user-NUC11TNHi5 systemd[1]: caddy.service: Failed with result 'exit-code'.
May 16 19:51:27 user-NUC11TNHi5 systemd[1]: Failed to start Caddy.

Here is what shows up when I run journalctl -xeu caddy.service

░ A start job for unit caddy.service has begun execution.
░░ 
░░ The job identifier is 5500.
May 16 19:56:51 user-NUC11TNHi5 caddy[18212]: caddy.HomeDir=/var/lib/caddy
May 16 19:56:51 user-NUC11TNHi5 caddy[18212]: caddy.AppDataDir=/var/lib/caddy/.local/share/caddy
May 16 19:56:51 user-NUC11TNHi5 caddy[18212]: caddy.AppConfigDir=/var/lib/caddy/.config/caddy
May 16 19:56:51 user-NUC11TNHi5 caddy[18212]: caddy.ConfigAutosavePath=/var/lib/caddy/.config/caddy/autosave.json
May 16 19:56:51 user-NUC11TNHi5 caddy[18212]: caddy.Version=v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=
May 16 19:56:51 user-NUC11TNHi5 caddy[18212]: runtime.GOOS=linux
May 16 19:56:51 user-NUC11TNHi5 caddy[18212]: runtime.GOARCH=amd64
May 16 19:56:51 user-NUC11TNHi5 caddy[18212]: runtime.Compiler=gc
May 16 19:56:51 user-NUC11TNHi5 caddy[18212]: runtime.NumCPU=8
May 16 19:56:51 user-NUC11TNHi5 caddy[18212]: runtime.GOMAXPROCS=8
May 16 19:56:51 user-NUC11TNHi5 caddy[18212]: runtime.Version=go1.20.3
May 16 19:56:51 user-NUC11TNHi5 caddy[18212]: os.Getwd=/
May 16 19:56:51 user-NUC11TNHi5 caddy[18212]: LANG=en_US.UTF-8
May 16 19:56:51 user-NUC11TNHi5 caddy[18212]: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
May 16 19:56:51 user-NUC11TNHi5 caddy[18212]: NOTIFY_SOCKET=/run/systemd/notify
May 16 19:56:51 user-NUC11TNHi5 caddy[18212]: HOME=/var/lib/caddy
May 16 19:56:51 user-NUC11TNHi5 caddy[18212]: LOGNAME=caddy
May 16 19:56:51 user-NUC11TNHi5 caddy[18212]: USER=caddy
May 16 19:56:51 user-NUC11TNHi5 caddy[18212]: INVOCATION_ID=32601e54466d4f879eb47c20a1e088ae
May 16 19:56:51 user-NUC11TNHi5 caddy[18212]: JOURNAL_STREAM=8:246483
May 16 19:56:51 user-NUC11TNHi5 caddy[18212]: SYSTEMD_EXEC_PID=18212
May 16 19:56:51 user-NUC11TNHi5 caddy[18212]: Error: reading config file: open /etc/caddy/Caddyfile: no such file or directory
May 16 19:56:51 user-NUC11TNHi5 systemd[1]: caddy.service: Main process exited, code=exited, status=1/FAILURE
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ An ExecStart= process belonging to unit caddy.service has exited.
░░ 
░░ The process' exit code is 'exited' and its exit status is 1.
May 16 19:56:51 user-NUC11TNHi5 systemd[1]: caddy.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ The unit caddy.service has entered the 'failed' state with result 'exit-code'.
May 16 19:56:51 user-NUC11TNHi5 systemd[1]: Failed to start Caddy.
░░ Subject: A start job for unit caddy.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░ 
░░ A start job for unit caddy.service has finished with a failure.
░░ 
░░ The job identifier is 5500 and the job result is failed.

The error message is pretty clear. You’re missing a Caddyfile config file.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.