小内存vps搭建环境的方案
typecho + caddy + php7.2 + sqlite3 + cloudflare
全部环境采取手动安装的方式
手动安装php7.2
走了不少弯路,这里总结出来给大家,就可以一次性成功了!
首先重装系统,采用debain10,重装大概10分钟装好
装好以后,先更改DNS为DNS64
echo -e "nameserver 2001:67c:2b0::4\nnameserver 2001:67c:2b0::6" > /etc/resolv.conf
执行相应的更新操作,以及安装必要的依赖
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
到这里就安装好了,更多的命令
systemctl restart php7.2-fpm #重启
systemctl start php7.2-fpm #启动
systemctl stop php7.2-fpm #关闭
systemctl status php7.2-fpm #检查状态
手动安装sqlite3
如果上面成功安装了php以后,这里就很简单了
apt install php7.2-sqlite3
创建数据库文件
mkdir /www/db
cd /www/db
sqlite3 testDB.db
创建以后给权限,否则安装博客无法读取
chmod -R 777 /www/db
手动安装caddy 配置php
新建一个文件夹,cd过去下载,然后解压
wget "https://caddyserver.com/download/linux/amd64?license=personal&telemetry=off" -O - | tar -xzv
新建Caddyfile文件,写入下面配置文件,
下面是typecho的配置文件,自己修改即可,这里使用自签名证书,cloudflare那边要设置为full模式
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}
}
}
启动caddy
./caddy > caddy.log 2>&1 &
下载安装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
下载以及使用本博客的模板
wget --no-check-certificate https://github.com/Zisbusy/Akina-for-Typecho/archive/v3.0.zip
mv /www/web/build/usr/themes/Akina-for-Typecho-3.0/Akina/* /www/web/build/usr/themes/Akina