ChatGPT刚出来的时候火热的一批, 正值我抑郁阶段, 一点想去看看的欲望都有。
后面快 2年了热度降了很多,找咩咩蹭海外手机号注册了 GPT 账号。
然后今年年初爆火的 DeekSeek也跟着注册账号玩了一下。
也拿MacMini M4 16G内存的机器本地部署ollama 跑大模型。
MacMini-M4:~$ ollama list
NAME ID SIZE MODIFIED
deepseek-coder-v2:latest 63fb193b3a9b 8.9 GB 3 days ago
llama3.2:latest a80c4f17acd5 2.0 GB 3 days ago


整体来说写代码 GPT 更好用些,deekseek用来写代码还是比较弱, 本地部署没有硬件资源支撑又慢又卡效率又低。
cursor 开始用觉得还行,后面发现一些模型会偷懒。
amazon q 也比较一般,用的比较少。
Copilot要钱,错过白嫖期没能体验上。
bolt.new 拿来写前端顺道写后端还不错。
整体一圈下来这些 AI模型只能当搜索引擎平替使用,只能拿他们当顾问或者知识库老炮当指导用(可以不厌其烦的从天文地理不限时间不限地点的给你回复), 想拿AI模型当牛当马用还是差得很远很远。
整体来说稍微输入量大一点后 AI 模型只能挑三拣四的回复或者是啰里巴嗦的写一大长串, 顶天也就局限在上下文上面回答, 身边的朋友和我聊过后的结论是这些AI写代码完全是人工智障。
如果是要整体结构性的布局出发和调整,再进行更新扩展增加等等AI模型就完全懵逼了(本地自己投喂训练的没玩过不太清楚), 想让 AI模型写代码还是得自己构思好, 然后拆分进行生成代码。
非要拿来搞全局通杀, 个人感觉写注释是个不错的路子。
主要对usr和var目录的 php 和 sqlite 文件保护。
把内容保存为/tmp/template.tpl 然后用clpctl 添加。
clpctl vhost-template:add --name='typecho' --file=/tmp/template.tpl
#{"rootDirectory":"","phpVersion":"8.3"}
server {
listen 80;
listen [::]:80;
listen 443 quic;
listen 443 ssl;
listen [::]:443 quic;
listen [::]:443 ssl;
http2 on;
http3 off;
{{ssl_certificate_key}}
{{ssl_certificate}}
{{server_name}}
{{root}}
index index.php index.html;
{{nginx_access_log}}
{{nginx_error_log}}
{{settings}}
if ($scheme != "https") {
rewrite ^ https://$host$request_uri permanent;
}
location ~ /.well-known {
auth_basic off;
allow all;
}
include /etc/nginx/global_settings;
location ~* ^/(usr|var)/.*\.(php|db)$ {
deny all;
return 403;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
try_files $uri =404;
fastcgi_read_timeout 3600;
fastcgi_send_timeout 3600;
fastcgi_param HTTPS "on";
fastcgi_param SERVER_PORT 443;
fastcgi_pass 127.0.0.1:{{php_fpm_port}};
fastcgi_param PHP_VALUE "{{php_settings}}";
}
location ~* ^.+\.(css|js|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|woff2|eot|mp4|ogg|ogv|webm|webp|zip|swf|map|mjs)$ {
add_header Access-Control-Allow-Origin "*";
add_header alt-svc 'h3=":443"; ma=86400';
expires max;
access_log off;
}
location ~ /\.(ht|svn|git) {
deny all;
}
if (-f $request_filename) {
break;
}
}
deb系列
apt update
apt install systemd-timesyncd -y
systemctl enable systemd-timesyncd.service --now
systemctl status systemd-timesyncd.service
RHEL系列
dnf -y update
dnf -y install systemd-timesyncd -y
systemctl enable systemd-timesyncd.service --now
systemctl status systemd-timesyncd.service
Postfix核心服务器设置
# -----------------------------
# 配置 Postfix 使用边缘服务器代理
# -----------------------------
echo "==> 配置 Postfix 使用边缘服务器代理发件"
# 登录到 MIAB,并设置 relayhost
sudo postconf -e "relayhost = [relay.example.com]:2525"
sudo postconf -e "smtp_use_tls = yes"
sudo postconf -e "smtp_tls_security_level = may"
sudo postfix reload
Postfix边缘服务器
#!/bin/bash
# -----------------------------
# Postfix 实际私网地址
MIAB_IP="10.0.0.2"
# -----------------------------
echo "==> 安装 Postfix 和相关邮件服务"
# 更新包列表并安装所需的软件
apt update
DEBIAN_FRONTEND=noninteractive apt install -y postfix
# 备份原配置
cp /etc/postfix/main.cf /etc/postfix/main.cf.bak.$(date +%s)
# -----------------------------
# 配置 Postfix 作为邮件代理
# -----------------------------
cat > /etc/postfix/main.cf <<EOF
myhostname = relay.example.com
myorigin = /etc/mailname
inet_interfaces = all
inet_protocols = all
mydestination =
relay_domains = *
transport_maps = hash:/etc/postfix/transport
smtpd_banner = relay.example.com ESMTP Proxy
disable_vrfy_command = yes
# 接受外部连接(可以根据需要更改限制)
smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination
mynetworks = 0.0.0.0/0
# 邮件转发到 MIAB(接收邮件)
local_recipient_maps =
mailbox_command =
EOF
# 添加 transport 映射
cat > /etc/postfix/transport <<EOF
* smtp:[${MIAB_IP}]
EOF
postmap /etc/postfix/transport
# 确保 Postfix 不加头部
# 创建 header_checks 文件
cat >/etc/postfix/header_checks <<EOF
/^Received:/ IGNORE
EOF
# 编译 header_checks
postmap /etc/postfix/header_checks
# 在 main.cf 中添加 header_checks 设置(如果不存在)
POSTFIX_MAIN_CF="/etc/postfix/main.cf"
if ! grep -q "^header_checks" "$POSTFIX_MAIN_CF"; then
echo "header_checks = pcre:/etc/postfix/header_checks" >> "$POSTFIX_MAIN_CF"
else
sed -i '/^header_checks/s|=.*|= pcre:/etc/postfix/header_checks|' "$POSTFIX_MAIN_CF"
fi
echo "[+] Postfix 已配置忽略 Received: 头部"
# -----------------------------
# 配置 Postfix 代理外发邮件
# -----------------------------
cat >> /etc/postfix/master.cf <<EOF
# 外发专用端口
2525 inet n - n - - smtpd
-o smtpd_authorized_xforward_hosts=${MIAB_IP}
-o smtpd_client_restrictions=permit_mynetworks,reject
-o receive_override_options=no_unknown_recipient_checks,no_header_body_checks
-o local_recipient_maps=
-o relay_domains=
-o smtpd_relay_restrictions=permit_mynetworks,reject
EOF
systemctl restart postfix
# -----------------------------
# 防火墙配置
# -----------------------------
ufw allow 25
ufw allow 2525
ufw --force enable
echo "✅ 边缘服务器已配置为邮件代理服务"
echo " - 25/2525 用于 SMTP 转发"
echo " - MIAB 完全不暴露"
echo " - 防火墙已配置,允许邮件端口访问"
echo "🚀 配置完成!"
LXD/incus ui的验证逻辑是创建一套 crt + pfx 证书, crt添加到服务器上,pfx导入到登录客户端,通过证书凭证进行验证。
apt install -y incus-ui-canonical #安装ui
incus config set core.https_address :8443 #配置端口
incus config show #查看配置
打开https://IP::8443/ui/login/certificate-generate
具体步骤如下:
点击“Generate”,生成incus-ui.crt和incus-ui.pfx后下载到本地, 把incus-ui.crt文件传服务器上用添加证书
incus config trust add-certificate incus-ui.crt #导入证书
incus config trust list #查看证书
导入incus-ui.pfx浏览器或者操作系统证书管理
然后重启浏览器用证书进行登录, pfx就是登录凭证。
另外还有个好玩的项目,可以集中管理所有服务器,https://github.com/PenningLabs/lxconsole
apt install python3 python3-pip git -y
git clone https://github.com/PenningLabs/lxconsole.git
cd lxconsole
pip3 install -r requirements.txt --break-system-packages
python3 run.py
基础安装完后创建账号登录进去, 添加 Server有提示如何生成证书,把证书内容保存到lxd服务器上再添加一下就可以直接管理了。

官方项目地址
https://github.com/lxc/incus
已有大神写好了基于 debian一键安装脚本
apt update -y
apt install curl -y
curl -SsL https://github.com/Hentioe/server-helpers/raw/refs/heads/main/debian-install-incus |bash
按照https://blog.hentioe.dev/posts/incus-usage.html的设置部署步骤基本大同小异, 也可以查看https://github.com/oneclickvirt/incus/
也可以参照官方的文档
https://linuxcontainers.org/incus/docs/main/tutorial/first_steps/
https://github.com/zabbly/incus
启动 webui
apt install -y incus-ui-canonical lsof
incus config set core.https_address :8443
incus config show
https://xxx.xxx.xxx.xxx:8443/ui/login
需要设置证书才能登录。
具体的只是初步安装看了一遍,配套整合管理软件没到位,暂时只能简单玩玩。
fallocate -l 120G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
swapon -s
echo "/swapfile none swap sw 0 0" >> /etc/fstab
mdadm --monitor --scan --daemonise --alert "bash /opt/mdadm_alert.sh"
或者指定阵列路径
mdadm --monitor /dev/md10 /dev/md1 --daemonise --alert "bash /opt/mdadm_alert.sh"
TG BOT通知脚本
#!/bin/bash
# 你的 Telegram Bot API Token 和 Chat ID(修改成你的)
TG_BOT_TOKEN="123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZ"
TG_CHAT_ID="987654321"
# 发送 Telegram 消息的函数
send_tg_message() {
MESSAGE="$1"
curl -s -X POST "https://api.telegram.org/bot$TG_BOT_TOKEN/sendMessage" \
-d "chat_id=$TG_CHAT_ID" \
-d "text=$MESSAGE" \
-d "parse_mode=Markdown"
}
# 获取 mdadm 提供的警告信息(传递给脚本的参数)
ALERT_MSG="🚨 *ALERT:* RAID issue detected!\n\n\`\`\`\n$1\n\`\`\`"
send_tg_message "$ALERT_MSG"
其实之前已经遇到过此问题了。
这次换Apple Silicon Mac版本后 brew 目录改到/opt目录。
brew install mtr
安装好后第一步先提权到 root,需要输入密码
sudo su
在 root 权限下后不用带 sudo 命令,设置权限。
ver=$(brew list mtr --versions| awk '{print $2}')
chown root `brew --prefix`/Cellar/mtr/$ver/sbin/mtr-packet
chmod 4755 `brew --prefix`/Cellar/mtr/$ver/sbin/mtr-packet
exit
过完年一次3600 价格买到了丐版MacMini M4
一直闲置没空,到这两天才买了2T 的第三方硬盘板替换。
提前下载好IPSW系统文件 https://mrmacintosh.com/apple-silicon-m1-full-macos-restore-ipsw-firmware-files-database/
在现有MAC上面apple store下载安装好apple configure
更换好硬盘板子后拿type-c线接背面的雷劈接口上。
按住开机键接上电源
状态灯变成闪烁黄色,
打开apple configure查看个设备状态,
虚线框内显示DFU的时候把IPSW文件拖动到虚线框,
状态灯变成白色即开始刷入数据,
如果接了显示器会看到logo和进度条,
等待 10 分钟左右完成刷机。

个人踩坑,搞了 2 小时都没有进入DFU模式,最后通过先按开机键再插电源一次性成功。
迁移数据
刷机用的type-c支持雷劈, 直接在雷劈网桥下设置PTP IP地址,然后打开迁移助手,十多分钟就迁移完数据了。
将老intel MacMini 数据迁移完后一些程序无法运行, 得安装Rosetta来兼容X86
softwareupdate --install-rosetta --agree-to-license
列出查看所有X86 版本的软件
system_profiler SPApplicationsDataType | grep -B 5 "Intel"
目前brew仍然安装不上,暂时未解决, 大致上完成了迁移使用,待续。
elrepo官方已经移除了centos7 的支持, 继续使用 CentOS7 高版本内核只有找一些稀有的归档存储源了。
https://mirrors.coreix.net/elrepo-archive-archive/kernel/el7/
https://dl.lamp.sh/kernel/el7/
elrepo最后一个 kernel 版本是 6.9.7-1.el7, 加上 almalinux延后支持,勉强可以继续使用。
curl -o /etc/yum.repos.d/CentOS-Base.repo https://el7.repo.almalinux.org/centos/CentOS-Base.repo
yum install -y http://repo.almalinux.org/elevate/elevate-release-latest-el$(rpm --eval %rhel).noarch.rpm
yum upgrade -y
yum install epel-release wget -y
rpm -ivh https://mirrors.coreix.net/elrepo-archive-archive/kernel/el7/x86_64/RPMS/{kernel-ml,kernel-ml-devel,kernel-ml-headers}-6.9.7-1.el7.elrepo.x86_64.rpm
grub2-set-default 0
grub2-mkconfig -o /boot/grub2/grub.cfg
reboot
openssh glibc 这些重要的包需要自己想办法处理。
没有能力玩透 Linux 的话建议还是使用新版本系统, 最头痛的是指定要旧版本的系统连yum仓库都不知道如何设定归档源,张口就说是故障问题要求额外的技术支持。
另外新版本的 openssl 已彻底放弃对sha1的支持。
参考文章https://www.oscarice.com/book/linux/centos7-last.html
组建 RAID 后重启, 阵列名变成了/dev/127
网上搜索了一下更新initramfs解决
update-initramfs -u
mdadm --detail --scan > /etc/mdadm/mdadm.conf
Centos 更新initramfs方法
dracut --force
另外重启网卡会导致kvm虚拟机网络离线,需要重启 libvirtd 才能恢复(网卡网桥模式),原因未知。
systemctl restart networking
systemctl restart libvirtd
auth_request /auth; 获取验证信息
server {
listen 8080;
resolver 1.1.1.1;
location @error401 { return 401 "Unauthorized"; }
location = /auth {
internal;
proxy_pass http://backend-server/authenticate;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location / {
auth_request /auth;
error_page 401 = @error401;
proxy_bind $server_addr;
proxy_pass $scheme://$http_host$request_uri;
proxy_set_header HOST $http_host;
proxy_buffers 256 4k;
proxy_max_temp_file_size 0k;
proxy_connect_timeout 30;
proxy_send_timeout 60;
proxy_read_timeout 60;
proxy_next_upstream error timeout invalid_header http_502;
}
deny 127.0.0.1;
}
PVE直接封装了WebSocket, 需要调用 VNC 和 xterm的几种方案:
1. 给虚拟机配置单独的 vnc监听端口和 ip并设置密码直接连接, 或者拿websockify转WebSocket
2.重新封装转发/api2/json/nodes/{node}/qemu/{vmid}/vncwebsocket
3.直接访问 PVE 原生接口方式。(1.直接访问 2.nginx单独封装反向代理xtermjs和novnc|)
前期准备
GET /api2/json/access/ticket
POST /api2/json/nodes/{node}/qemu/{vmid}/vncproxy
wss /api2/json/nodes/{node}/qemu/{vmid}/vncwebsocket
vncproxy 和 ticket 需要一起创建,noVNC连接vncwebsocket 需要 PVEAuthCookie才能正常通信否则无法连接。
注意:请求/api2/json/access/ticket必须要用户密码获取,用root token无法创建。
PVE 的设计思路是将 VM 分配给用户,但是没给token设计获取 ticket 应该是考虑权限分离。
偷懒思路解决方案,直接nginx代理 PVE 的 noVNC和xterm(又不想开放 PVE 访问)
map $arg_node $proxyhost {
"PVE NODE NAME-1" "PVE IP";
"PVE NODE NAME-1" "PVE IP";
"PVE NODE NAME-1" "PVE IP";
}
location ~/(xtermjs|novnc|api2) {
if ( $arg_console ) { set $new_uri /?$query_string; }
proxy_pass https://$proxyhost:8006$new_uri;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
如果有安装 redis 插件, 可以从 redis 存取主机 IP, 另外还有一个版本由于安全问题暂不公开。
和代理websocket方法一样也是需要保证wss通信的时候要带上PVEAuthCookie的 cookies
阅读剩余部分...
- 1
- 2
- 3
- 4
- ...
- 64
- »