分类 Caddy 下的文章

root@mail:~# 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/xcaddy@latest

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

安装请Caddy请参考 Ubuntu 安装最新版本 Caddy

add-apt-repository ppa:ondrej/php
apt install php-cli php-fpm php-mysql
php --version

php配置文件路径 /etc/php/8.1/fpm/pool.d/www.conf

cd /var/www
从这里找到下载地址 https://cn.wordpress.org/download/
wget https://cn.wordpress.org/latest-zh_CN.tar.gz
tar –xvzf latest.tar.gz

vim /etc/caddy/Caddyfile
blog.domain.com {

root * /var/www/wordpress
php_fastcgi unix//run/php/php8.1-fpm.sock    
file_server

}

systemctl restart php8.1-fpm
systemctl restart caddy

echo '<?php phpinfo() ?>' > /var/www/wordpress/info.php
https://blog.domain.com/info.php 应该可以访问了

chown -R www-data:www-data /var/www/wordpress
:set paste

删除MySql某个库的所有表:
select concat('drop table ',table_name,';') as sql from information_schema.TABLES where table_schema='myblog';
复制出来的信息执行即可