0%

轻量博客搭建(tcpsc)

typecho+caddy+php7+sqlite3+cloudflare

系统Debian10:
执行相应的更新操作,以及安装必要的依赖

apt update
apt install lsb-release
apt install net-tools

优化打开文件的限制次数,默认的打开文件数是1024:

echo '* soft nofile 51200
* hard nofile 51200' >> /etc/security/limits.conf

ulimit -n 51200

echo 'fs.file-max = 51200
net.core.rmem_max = 67108864
net.core.wmem_max = 67108864
net.core.netdev_max_backlog = 250000
net.core.somaxconn = 4096
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.ip_local_port_range = 10000 65000
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_mem = 25600 51200 102400
net.ipv4.tcp_rmem = 4096 87380 67108864
net.ipv4.tcp_wmem = 4096 65536 67108864
net.ipv4.tcp_mtu_probing = 1
net.ipv4.tcp_congestion_control = hybla' >> /etc/sysctl.conf

sysctl -p

更新php7.2的软件源

#添加GPG
wget -O /etc/apt/trusted.gpg.d/php.gpg https://mirror.xtom.com.hk/sury/php/apt.gpg

#安装apt-transport-https
apt-get install apt-transport-https

#添加sury软件源
sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'

#更新软件源缓存
apt-get update

安装php 7.2

apt install php7.2-fpm php7.2-mysql php7.2-curl php7.2-gd php7.2-mbstring php7.2-xml php7.2-xmlrpc php7.2-zip php7.2-opcache -y

设置php

sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/' /etc/php/7.2/fpm/php.ini 

php更多命令:

systemctl restart php7.2-fpm  #重启
systemctl start php7.2-fpm  #启动
systemctl stop php7.2-fpm  #关闭
systemctl status php7.2-fpm  #检查状态

安装sqlite3

apt install php7.2-sqlite3
#创建数据库文件
mkdir /www/db #示例
cd /www/db
sqlite3 testDB.db
#创建以后权限加满,可读写
chmod -R 777 /www/db

安装caddy:

#下载并解压Caddy
wget "https://caddyserver.com/download/linux/amd64?license=personal&telemetry=off" -O - | tar -xzv

#新建并写入Caddyfile,目录最好放在Caddy下
https://yourdomain.com {
    root /www/web/bulid
    tls self_signed
    fastcgi / /run/php/php7.2-fpm.sock php { 
        ext .php
        split .php
        index index.php
   }
   proxy /hello 127.0.0.1:10000 {
      websocket
      header_upstream -Origin
    }
   rewrite {
        if {path} not_match ^\/admin
        to {path} {path}/ /index.php?{query}
    }
}

使用自签名证书,cloudflare的Catch需要设置Full模式。

启动Caddy:

./caddy > caddy.log 2>&1 &

相关命令:

启动:systemctl start caddy
停止:systemctl stop caddy
重启:systemctl restart caddy

安装typecho:

#下载
wget --no-check-certificate https://github.com/typecho/typecho/releases/download/v1.1-17.10.30-release/1.1.17.10.30.-release.tar.gz -O typecho.tar.gz
tar -zxvf typecho.tar.gz -C  /www/web
#使用本Blog模板
wget --no-check-certificate  https://github.com/Zisbusy/Akina-for-Typecho/archive/v3.0.zip
mv /Akina-for-Typecho-3.0/Akina/*  /www/web/build/usr/themes/Akina

大功告成!

欢迎关注我的其它发布渠道