[email protected]:~# whereis caddy
caddy: /etc/caddy /usr/local/bin/caddy

Thank you. So the apt pkg installs the binary in /usr/bin, but you have the old caddy placed in /usr/local/bin/caddy.
If you run echo $PATH you'll see /usr/local/bin somewhere to the left of /usr/bin.
This means when you run the command caddy, the OS will search for the executable through the directories listed in $PATH from left to right, and will find it in /usr/local/bin (which is v1) before it finds the one in /usr/bin (which is v2).

If your “installation” of v1 was using getcaddy.com or manually placing the executable in /usr/local/bin, then resolving this should be as simple as removing the /usr/local/bin/caddy executable.

v1中文文档:https://www.bookstack.cn/read/caddy-cn-doc/README.MD
v2中文文档:https://caddy2.dengxiaolong.com/docs/
官方:https://caddyserver.com/docs/

卸载
kill 进程
systemctl disable caddy.service
rm /usr/local/bin/caddy

二进制安装:
先下载,如果需要模块的,可下载带模块的(注意选择正确的平台,arch 命令查看)
https://github.com/caddyserver/caddy/releases
https://caddyserver.com/download

下载deb安装:
wget https://github.com/caddyserver/caddy/releases/download/v2.4.6/caddy_2.4.6_linux_amd64.deb
dpkg -i caddy_2.4.6_linux_amd64.deb

直接下载程序包:
mv caddy /usr/bin/
chmod -R 777 /usr/bin/caddy
caddy version
vim /etc/systemd/system/caddy.service
内容在:https://github.com/caddyserver/dist/blob/master/init/caddy.service
groupadd --system caddy
useradd --system --gid caddy --create-home --home-dir /var/lib/caddy --shell /usr/sbin/nologin --comment "Caddy web server" caddy
systemctl daemon-reload
systemctl enable --now caddy
systemctl status caddy

直接安装:
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo tee /etc/apt/trusted.gpg.d/caddy-stable.asc
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

源码安装(其它模块):
git clone "https://github.com/caddyserver/caddy.git"
cd caddy/cmd/caddy/

安装 xcaddy----------------------------------------------------------------------
直接安装方式:
apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/xcaddy/gpg.key' | sudo tee /etc/apt/trusted.gpg.d/caddy-xcaddy.asc
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/xcaddy/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-xcaddy.list
apt update
apt install xcaddy

Go 安装方式:先安装 go (https://go.dev/doc/install):
wget https://go.dev/dl/go1.18.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.18.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
go version

再安装 xcaddy

go install github.com/caddyserver/xcaddy/cmd/[email protected]

安装带 replace-response 模块的 Caddy
xcaddy build --with github.com/caddyserver/replace-response

标签: none

添加新评论