Build from source
- Go 1.14 or newer
Clone the repository:
git clone "https://github.com/caddyserver/caddy.git"
cd caddy/cmd/caddy/ go build
xcaddy command is the easiest way to build Caddy with version information and/or plugins.
- Go installed (see above)
- Make sure xcaddy is in your PATH
You do not need to download the Caddy source code (it will do that for you).
Then building Caddy (with version information) is as easy as:
To build with plugins, use
xcaddy build \ --with github.com/caddyserver/nginx-adapter --with email@example.com
As you can see, you can customize the versions of plugins with
@ syntax. Versions can be a tag name or commit SHA.
Cross-platform compilation with
xcaddy works the same as with the
go command (see below).
Go programs are easy to compile for other platforms. Just set the
GOARM environment variables that are different. (See the go documentation for details.)
For example, to compile Caddy for Windows when you're not on Windows:
GOOS=windows go build
Or similarly for Linux ARMv6 when you're not on Linux or on ARMv6:
GOOS=linux GOARCH=arm GOARM=6 go build
The same works for
xcaddy. To cross-compile for macOS:
GOOS=darwin xcaddy build