分类 默认分类 下的文章

安装 docker

curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh

改变目录权限

chown -R 1000.1000 /home/caddy/www

配置 Caddyfile

hantu.win {
    tls [email protected]
    root /srv
    header / Strict-Transport-Security "max-age=31536000;"
    gzip
    log /root/hantu_win.log
    fastcgi / 127.0.0.1:9000 php
    on startup php-fpm7
}

www.hantu.win {
    redir https://hantu.win{uri}
}
blog.hantu.win {
    redir https://hantu.win{uri}
}

docker 运行

docker run -d \
--name=caddy \
--restart=always \
-e ACME_AGREE=true \
-v /home/caddy/Caddyfile:/etc/Caddyfile \
-v /home/caddy/.caddy:/root/.caddy \
-v /home/caddy/www:/srv \
-p 80:80 -p 443:443 -p 2015:2015 \
abiosoft/caddy:php

将 www 目录放到 home 目录
安装 php sqlite

apt install sqlite php7.0-fpm php7.0-sqlite php7.0-xml php7.0-gd 

安装 Caddy

curl https://getcaddy.com | bash -s personal

创建 Caddy 配置文件

mkdir /etc/caddy
vi /etc/caddy/Caddyfile

编辑内容

hantu.win {
    tls [email protected]
    root /home/www
    header / Strict-Transport-Security "max-age=31536000;"
    gzip
    log /home/hantu_win.log
    fastcgi / /run/php/php7.0-fpm.sock php
}

www.hantu.win {
    redir https://hantu.win{uri}
}
blog.hantu.win {
    redir https://hantu.win{uri}
}

创建 Caddy 服务

vi /etc/systemd/system/caddy.service

编辑内容

[Unit]
Description=caddy

[Service]
ExecStart=/usr/local/bin/caddy -conf /etc/caddy/Caddyfile
Restart=always
  
[Install]
WantedBy=multi-user.target

加入自启动

systemctl enable caddy
systemctl start caddy