Caddy 最新版搭建 mkdocs
服务器:Centos7.2
01.基础环境搭建
1.1.安装 golang
1rpm --import https://mirror.go-repo.io/centos/RPM-GPG-KEY-GO-REPO
2curl -s https://mirror.go-repo.io/centos/go-repo.repo | tee /etc/yum.repos.d/go-repo.repo
3yum install golang
1.2.安装 xcaddy
xcaddy 是 caddy 的简易安装方式
1go get -u github.com/caddyserver/xcaddy/cmd/xcaddy
2cd go/src/github.com/caddyserver/xcaddy/cmd/xcaddy
3go build && cp xcaddy /usr/bin
编译安装最新的 caddy,插件自行选择编译
1xcaddy build \
2 --with github.com/caddyserver/nginx-adapter \
3 --with github.com/caddyserver/[email protected]
4cp /root/go/src/github.com/caddyserver/xcaddy/cmd/xcaddy/caddy /usr/local/bin/
查看安装的 caddy 版本
1[[email protected] xcaddy]# caddy version
2v2.1.1 h1:X9k1+ehZPYYrSqBvf/ocUgdLSRIuiNiMo7CvyGUQKeA=
02.安装 caddy 服务
2.1 添加用户和用户组
1sudo groupadd --system caddy
2sudo useradd --system \
3 --gid caddy \
4 --create-home \
5 --home-dir /var/lib/caddy \
6 --shell /usr/sbin/nologin \
7 --comment "Caddy web server" \
8 caddy
/etc/systemd/system/caddy.service 文件内容
1# caddy.service
2#
3# For using Caddy with a config file.
4#
5# Make sure the ExecStart and ExecReload commands are correct
6# for your installation.
7#
8# See https://caddyserver.com/docs/install for instructions.
9#
10# WARNING: This service does not use the --resume flag, so if you
11# use the API to make changes, they will be overwritten by the
12# Caddyfile next time the service is restarted. If you intend to
13# use Caddy's API to configure it, add the --resume flag to the
14# `caddy run` command or use the caddy-api.service file instead.
15
16[Unit]
17Description=Caddy
18Documentation=https://caddyserver.com/docs/
19After=network.target
20
21[Service]
22User=caddy
23Group=caddy
24ExecStart=/usr/bin/caddy run --environ --config /root/mkdocs-caddyy/Caddyfile
25ExecReload=/usr/bin/caddy reload --config /root/mkdocs-caddyy/Caddyfile
26TimeoutStopSec=5s
27LimitNOFILE=1048576
28LimitNPROC=512
29PrivateTmp=true
30ProtectSystem=full
31AmbientCapabilities=CAP_NET_BIND_SERVICE
32
33[Install]
34WantedBy=multi-user.target
caddy adapter 支持下述配置文件
caddyfile (standard)
nginx
jsonc
json5
YAML
cue
toml
2.2 运行 caddy 服务
启动 caddy 服务
1service caddy start
安装 mkdocs
1git clone https://github.com/squidfunk/mkdocs-material.git
2pip3 install -r mkdocs-material/requirements.txt
3mkdocs new .
4mkdocs serve
2.3 访问测试
http://wiki.opschina.top:8001
截图:
附录:
Caddyfile 文件内容
1http://wiki.opschina.top:8001 {
2reverse_proxy 127.0.0.1:8000
3}
---------------------------------------------------------------
>> 博客地址:https://blog.mufengs.com
>> 邮箱地址:[email protected]
>> 微信帐号:Do8080
>> Github : https://github.com/mufengcoding
---------------------------------------------------------------