centos8 启动一个 caddy 作为文件服务器

1、下载并安装 caddy

curl -OL https://github.com/caddyserver/caddy/releases/download/v2.6.4/caddy_2.6.4_linux_amd64.tar.gz
tar -zxvf caddy_2.6.4_linux_amd64.tar.gz caddy
mv caddy /usr/local/bin
chmod +x /usr/local/bin/caddy
rm caddy_2.6.4_linux_amd64.tar.gz -rf

 

2、创建 Caddyfile 配置文件

mkdir -p /data
mkdir -p /etc/caddy/
cat > /etc/caddy/Caddyfile << EOF
:2015 {
  file_server {
    root /data
    hide .*
    browse
  }
}
EOF

 

3、开启自启动

在 /etc/rc.local 添加如下内容

nohup caddy run --adapter caddyfile --config /etc/caddy/Caddyfile > /var/log/caddy.log 2>&1 &
chmod +x /etc/rc.local

 

posted @ 2022-07-04 15:59  Nihaorz  阅读(467)  评论(0编辑  收藏  举报