caddy-website/src/docs/markdown/install.md
2021-04-05 13:31:03 -06:00

7.6 KiB

title
Install

Install

This page describes various methods for installing Caddy on your system.

Official:

Community-maintained:

Static binaries

Simply downloading a Caddy binary does not install it as a service, but can be useful in dev or when upgrading an existing installation.

Debian, Ubuntu, Raspbian

Installing this package automatically starts and runs Caddy for you as a systemd service named caddy using our official caddy.service unit file.

This package also comes with a caddy-api systemd service using our official caddy-api.service unit file, which is disabled by default. If you plan to configure Caddy solely through its API, then you should disable the caddy service, and enable the caddy-api service.

Stable releases:

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo apt-key add -
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

Testing releases (includes betas and release candidates):

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/testing/gpg.key' | sudo apt-key add -
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/testing/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-testing.list
sudo apt update
sudo apt install caddy

View the Cloudsmith repos

Fedora, RedHat, CentOS

Fedora or RHEL/CentOS 8:

dnf install 'dnf-command(copr)'
dnf copr enable @caddy/caddy
dnf install caddy

RHEL/CentOS 7:

yum install yum-plugin-copr
yum copr enable @caddy/caddy
yum install caddy

View the Caddy COPR

Arch Linux, Manjaro, Parabola

pacman -Syu caddy

View Caddy in the Arch Linux repositories

Docker

docker pull caddy

View on Docker Hub

DigitalOcean

Deploy a Caddy droplet on DigitalOcean

Linux service

Manually install Caddy as a service on Linux with these instructions.

Requirements:

Move the caddy binary into your $PATH, for example:

sudo mv caddy /usr/bin/

Test that it worked:

caddy version

Create a group named caddy:

sudo groupadd --system caddy

Create a user named caddy, with a writeable home folder:

sudo useradd --system \
    --gid caddy \
    --create-home \
    --home-dir /var/lib/caddy \
    --shell /usr/sbin/nologin \
    --comment "Caddy web server" \
    caddy

If using a config file, be sure it is readable by the caddy user you just created.

Next, choose a systemd service file based on your use case:

They are very similar but have minor differences in the ExecStart and ExecReload commands to accommodate your workflow. Customize the file accordingly.

Double-check the ExecStart and ExecReload directives. Make sure the binary's location and command line arguments are correct for your installation! For example: if using a config file, change your --config path if it is different from our example.

The usual place to save the service file is: /etc/systemd/system/caddy.service

After saving your service file, you can start the service for the first time with the usual systemctl dance:

sudo systemctl daemon-reload
sudo systemctl enable caddy
sudo systemctl start caddy

Verify that it is running:

systemctl status caddy

When running with our official service file, Caddy's output will be redirected to journalctl:

journalctl -u caddy --no-pager | less

If using a config file, you can gracefully apply any changes:

sudo systemctl reload caddy

You can stop the service with:

sudo systemctl stop caddy

Homebrew

Note: This is a community-maintained installation method.

brew install caddy

View the Homebrew formula

Webi

Note: This is a community-maintained installation method.

Linux and macOS:

curl -sS https://webinstall.dev/caddy | bash

Windows:

curl.exe -A MS https://webinstall.dev/caddy | powershell

You may need to adjust the Windows firewall rules to allow non-localhost incoming connections.

View on Webi

Chocolatey

Note: This is a community-maintained installation method.

choco install caddy

View the Chocolatey package

Ansible

Note: This is a community-maintained installation method.

ansible-galaxy install nvjacobo.caddy

View the Ansible role repository