开头先吐槽一下我看不懂的Caddy Doc, 是真的看不懂
再吐槽一下Typecho的Markdown解释器,wdnmd


  • 前期准备

    1. 需要一台CentOS 7系统主机 [RH7也行,你开心就好] (略)
    2. 需要一个域名(略)
    3. 安装epel源,用黄狗或者RPM:
      sudo yum install epel-release

      sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    4. 安装webtatic源,由于CentOS官方源+epel源中仅提供了5.4版本的rpm,秉承着安新不安旧的原则,我选择安装7.2版本,这里就需要添加webtatic源:
      sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
    5. 刷新Cache
      sudo yum makecache
    6. (可选) 安装Wget
      sudo yum install wget -y
  • 安装阶段

    1. 首先安装Caddy
      sudo yum install caddy -y
    2. 其次安装PHP7.2
      sudo yum install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-fpm php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml -y
    3. 然后安装MariaDB
      sudo yum install mariadb mariadb-server -y
    4. 最后下载Typecho{这里使用Stable v1.1 (17.10.30), 我对版本没啥特殊要求}
      wget -O "typecho.tar.gz" http://typecho.org/downloads/1.1-17.10.30-release.tar.gz
  • 配置阶段

    • 配置Caddy
    • 配置Caddy.conf
      caddy使用所谓指令(Directives)来描述功能进行配置,所以首先配置他,简易配置见本文尾部
    • 创建日志文件并修改权限
      sudo mkdir /var/log/caddy && touch /var/log/caddy/caddy.log
      sudo chown caddy:caddy /var/log/caddy/caddy.log
    • 配置PHP
      sudo vi /etc/php-fpm.d/www.conf
      修改如下参数
      user = caddy
      group = caddy
      listen = 127.0.0.1:9000
    • 配置MariaDB
      sudo mysql_secure_installation
      根据提示设定数据库密码,初始化配置(个人配置为YNYY
      创建typecho数据库
      mysql -uroot -p -se "create database typecho;"
    • 配置Typecho
      解压typecho
      tar -zxvf typecho.tar.gz
      移动内容至Caddy目录
      mv build/ /usr/share/caddy/
  • 启动阶段

    • 启动php-fpm并设定开机自起
      systemctl restart php-fpm && systemctl enable php-fpm
    • 启动MariaDB并设定开机自起
      systemctl restart mariadb && systemctl enable mariadb
    • 启动Caddy并设定开机自起
      systemctl restart caddy && systemctl enable caddy

然后就可以进入Typecho的初始化页面进行配置啦!

####PS:Caddy.conf####

:80  
{  
gzip  
redir https://(1).(2){url}  
}  
(1).(2)  
{  
root /usr/share/caddy  
log /var/log/caddy/caddy.log  
tls "YOUR MAIL ADDR"  
fastcgi / 127.0.0.1:9000 php  
rewrite {  
if {path} not_match ^\/admin  
to {path} {path}/ /index.php?{query}  
}  
}  
www.(2) {  
log /var/log/caddy/caddy.log  
tls "YOUR MAIL ADDR"  
redir https://(1).(2){url}  
}  
import conf.d/*.conf 

说明

'(1)'是指A记录所解析的部分
'(2)'指域名
'tls' 为你的邮箱地址'用于Let's Encrypt证书下发