请注意,本文编写于 79 天前,最后修改于 79 天前,其中某些信息可能已经过时。
个人自用快速部署typecho博客,嘿嘿😁😁
环境准备
默认是全新的环境哦
系统: Debian GNU/Linux 10 (buster)
内核: 4.19.0-6-amd64
PHP: 7.3.9
初始化环境
自用debian初始化playbook
git clone https://github.com/ysicing/play-ansible.git
cd play-ansible
# 安装ansible
./install.sh
# 编辑inventory.ini,添加节点ip(已配置ssh信任登录)
# 执行初始化
ansible-playbook init.yml
安装docker
快速一键安装docker
curl https://raw.githubusercontent.com/ysicing/func/master/docker.sh | bash
架构说明
基于docker
+ caddy
+ sqlite3
+ typecho
容器化部署
通过docker-compose.yaml
部署
docker-compose.yaml
version: '2.1'
services:
caddy:
image: ysicing/caddy
container_name: caddy
volumes:
- ./ssl:/root/.caddy
- /var/log/caddy:/var/log/caddy
- ./Caddyfile:/etc/Caddyfile
- /root/.ssh:/root/.ssh
- ./php:/srv
network_mode: host
restart: always
caddy
caddy镜像,我做了一些改动,源码参考 caddy-docker
Caddyfile
godu.dev {
gzip
prometheus
log / /var/log/caddy/blog.log "{remote} {when} {method} {uri} {proto} {status} {size} {>User-Agent} {latency}" {
rotate_size 50
rotate_age 90
rotate_keep 20
rotate_compress
}
errors {
* /etc/404.html
}
tls root@ysicing.net
header / {
X-Via Ucloud.CN.Beijing
Strict-Transport-Security "max-age=31536000;includeSubDomains;preload"
-Server
}
root /srv/godu.dev
fastcgi / 127.0.0.1:9000 php
rewrite {
if {path} not_match ^\/admin
to {path} {path}/ /index.php?{query}
}
on startup php-fpm7
status 403 {
/changelog.txt
/config.inc.php
/config
/install
/install.php
/tools
/usr/<马赛克>.db
/var
}
}
部署typecho
root@kvm03.vps:~/web# ls
Caddyfile docker-compose.yaml php prom ssl
-----
# 部署typecho
cd php
git clone https://github.com/typecho/typecho.git godu.dev
cd ..
docker-compose up -d
到这里基本上就完成了,后续就是通过界面部署,点点点。哈哈哈
使用handsome
- 上传主题到
/root/web/php/godu.dev/usr/themes
,且主题名为handsome
- 上传插件到
/root/web/php/godu.dev/usr/plugins
,且插件名为Handsome
如有问题,请检查权限。如数据库问题,可能是/root/web/php/godu.dev/usr
没有写权限,容器内是www-user
,宿主机是root
其他
真香,准备从hugo换到typecho哈哈哈
自用插件列表
- AutoTags
- CodePrettify
- EditorMD
- LoveKKComment
- ShortLinks
- Sitemap
- SmartSpam
- Sticky
- UserAgent
hugo重定向问题
hugo博客配置
# docker-compose.yaml
version: '2.1'
services:
caddy:
image: spanda/caddy:hugo
container_name: caddy
volumes:
- ./ssl:/root/.caddy
- /var/log/caddy:/var/log/caddy
- ./Caddyfile:/etc/Caddyfile
- ./GeoLite2.mmdb:/etc/GeoLite2.mmdb
- /root/.ssh:/root/.ssh
network_mode: host
restart: always
# Caddyfile
ysicing.me {
gzip
prometheus
log / /var/log/caddy/blog.log "{remote} {when} {method} {uri} {proto} {status} {size} {>User-Agent} {latency}" {
rotate_size 50
rotate_age 90
rotate_keep 20
rotate_compress
}
geoip /etc/GeoLite2.mmdb
tls i@ysicing.me
header / {
Strict-Transport-Security "max-age=31536000;includeSubDomains;preload"
Access-Control-Allow-Origin *
Access-Control-Allow-Methods "GET, POST, OPTIONS"
X-XSS-Protection "1; mode=block"
X-Content-Type-Options "nosniff"
X-Frame-Options "SAMEORIGIN"
-Server
}
redir 302 {
if {geoip_country_code} is "CN"
/ https://godu.dev
}
errors {
* /tmp/404.html
}
root /tmp/blog/public
git {
repo git@<马赛克地址>.git
path /tmp/blog
branch master
key /root/.ssh/id_rsa
then hugo --destination=/tmp/blog/public
hook /webhook <马赛克地址>
hook_type github
clone_args --recursive
pull_args --recurse-submodules
interval 86400
}
hugo
}
当访问hugo博客是中国(CN)IP时会重定向本博客,嘻嘻
容器化部署你值得拥有
版权属于:ysicing
本文链接:https://godu.dev/posts/handsome-typecho-docker/
转载时须注明出处及本声明