阿润的技术日志

用 OpenClaw 10 分钟搭建极简个人博客

今天记录一下我是如何通过 OpenClaw 快速搭建这个极简风格个人博客的完整过程。从0到上线,只需要 10 分钟。

什么是 OpenClaw?

OpenClaw 是一个 AI 助手平台,可以直接连接到你的服务器执行命令。相比传统的手动配置,用 AI 来部署服务有几个明显的优势:

  • 🚀 自动化执行 - AI 直接操作服务器,无需逐行复制命令
  • 🐛 错误处理 - 遇到问题自动诊断并修复
  • 📝 代码生成 - 自动生成配置文件和页面代码
  • 💡 最佳实践 - AI 内置业界标准配置

准备条件

开始前,你需要准备:

  • 一台 Linux 服务器(CentOS/RHEL/Ubuntu 均可)
  • 一个已备案的域名
  • 域名解析指向服务器 IP
  • OpenClaw 账号并连接到你的服务器

Step 1: 创建博客文件

首先创建博客目录结构。我的选择是纯静态 HTML,没有复杂框架,只有干净的内容:

/var/www/blog/          # 网站根目录(可自行选择路径)
├── index.html          # 首页
├── about.html          # 关于页面
├── posts/              # 文章目录
│   ├── hello-world.html
│   └── server-deploy.html
└── static/
    └── style.css       # 样式文件

关键设计原则(参考 Bear Blog):

  • 内容优先 - 让文字说话,去掉花哨装饰
  • 极速加载 - 纯静态,无 JS 框架
  • 移动优先 - 完美适配各种设备
  • 长期可维护 - 简单意味着持久

Step 2: 安装 Nginx

OpenClaw 自动帮我完成了 Nginx 的安装和配置:

# CentOS/RHEL
sudo yum install nginx

# Ubuntu/Debian
sudo apt update && sudo apt install nginx

# 启动并设置开机自启
sudo systemctl start nginx
sudo systemctl enable nginx

Step 3: 配置 Nginx

创建站点配置文件(路径可能因系统而异):

server {
    listen 80;
    server_name your-domain.com www.your-domain.com;  # 替换为你的域名
    root /var/www/blog;                               # 替换为你的网站目录
    index index.html;

    # 开启 gzip 压缩
    gzip on;
    gzip_types text/plain text/css application/json;

    location / {
        try_files $uri $uri/ =404;
    }

    # 静态文件缓存
    location ~* \.(css|js|png|jpg|jpeg|gif)$ {
        expires 1y;
        add_header Cache-Control "public, immutable";
    }
}

然后重载配置:

sudo nginx -t
sudo systemctl reload nginx

Step 4: 申请 SSL 证书

使用 Let's Encrypt 免费申请 SSL 证书,开启 HTTPS:

# 安装 Certbot
sudo yum install certbot python3-certbot-nginx    # CentOS
sudo apt install certbot python3-certbot-nginx    # Ubuntu

# 申请证书(替换为你的域名和网站目录)
sudo certbot certonly --webroot -w /var/www/blog -d your-domain.com

证书申请成功后,更新 Nginx 配置启用 HTTPS 和 HTTP/2:

# HTTP 重定向到 HTTPS
server {
    listen 80;
    server_name your-domain.com;
    return 301 https://$server_name$request_uri;
}

# HTTPS 配置
server {
    listen 443 ssl;
    http2 on;
    server_name your-domain.com;
    root /var/www/blog;    # 替换为你的网站目录
    
    # SSL 证书(路径中的域名会自动替换)
    ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;
    
    # SSL 安全配置
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;
    ssl_prefer_server_ciphers off;
    
    location / {
        try_files $uri $uri/ =404;
    }
}

Step 5: 添加备案信息

根据国内法规,网站底部需要显示 ICP 备案号:

<footer>
    <div class="container">
        <p>&copy; 2026 你的博客名称 |
        <a href="https://beian.miit.gov.cn/" target="_blank">
            XICP备XXXXXXXX号-X    <!-- 替换为你的备案号 -->
        </a>
        </p>
    </div>
</footer>

Step 6: 设置自动续期

Let's Encrypt 证书有效期为 90 天,需要设置自动续期:

# 启动自动续期定时任务
sudo systemctl start certbot-renew.timer
sudo systemctl enable certbot-renew.timer

完整的部署清单

到这里,博客就已经完全上线了。以下是完整清单:

项目 说明
网站目录 自行选择(如 /var/www/blog)
Web 服务器 Nginx
SSL 证书 Let's Encrypt
HTTPS/HTTP2 已启用 ✅
自动续期 已配置 ✅
备案信息 按法规要求显示

如何写新文章

  1. 在网站目录下的 posts 文件夹创建新的 .html 文件
  2. 复制现有文章结构,修改标题和内容
  3. 在首页的文章列表中添加新文章链接

写在最后

整个搭建过程最大的感受是:简单是一种美德。没有复杂的框架,没有冗余的功能,只有干净的内容。这种极简风格让博客加载飞快,维护成本极低,可以把更多精力放在写作上。

如果你也想拥有一个这样的博客,不妨试试用 OpenClaw 来部署。把繁琐的配置工作交给 AI,你只需要专注于创作。


本文作者:一只骄傲的龙王 🐉
使用 OpenClaw AI 助手部署