前言
最近入手了阿里云轻量应用服务器,99 元/年的价格非常香。我决定在这台服务器上部署 Hexo 博客——一个快速、简洁的博客框架。
本文将完整记录从服务器购买到博客部署的全过程,包含所有踩坑经验和解决方案。
服务器配置
基本信息
- 平台: 阿里云轻量应用服务器
- 价格: 99 元/年
- 配置: 2 核 2G 40G 磁盘
- 系统: Alibaba Cloud Linux 3
- 位置: 华东 1(杭州)
购买建议
- 选择离你最近的区域(降低延迟)
- 至少 40G 磁盘(博客 + 图片需要空间)
- 建议选择 Linux 系统(Ubuntu/CentOS/Alibaba Cloud Linux)
环境准备
1. 安装 Node.js
Hexo 需要 Node.js v20+ 环境:
1 2 3 4 5 6 7 8
| node --version npm --version
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash source ~/.bashrc nvm install 22
|
2. 安装 Hexo CLI
1 2
| npm install -g hexo-cli hexo version
|
创建博客
1. 初始化博客
1 2 3 4 5 6 7
| mkdir -p /root/tech-blog cd /root/tech-blog
hexo init npm install
|
2. 安装 Next 主题
1 2
| git clone https://github.com/next-theme/hexo-theme-next themes/next
|
配置博客
编辑 _config.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| title: 运维技术笔记 subtitle: OpenClaw / 服务器 / AI 本地化 description: 记录分布式服务器部署与 AI 运维实战 keywords: Hexo,服务器运维,AI,分布式,博客 author: 寒呀 language: zh-CN
url: https://ops-blog.tech root: / permalink: :year/:month/:day/:title/
theme: next
|
创建文章
1. 新建文章
1
| hexo new post "99 元服务器部署 Hexo 博客全流程"
|
2. 编辑文章
文章位于 source/_posts/ 目录,使用 Markdown 格式:
1 2 3 4 5 6 7 8 9
| --- title: 文章标题 date: 2026-04-12 tags: [标签 1, 标签 2] categories: 分类 ---
## 正文内容 ...
|
生成博客
1 2 3 4 5 6 7 8
| hexo clean
hexo generate
hexo server -p 4000
|
部署博客
方式一:Python HTTP 服务(简单)
1 2 3 4 5 6 7
| cd /root/tech-blog/public
nohup python3 -m http.server 8080 &
|
方式二:systemd 服务(推荐)
创建服务文件 /etc/systemd/system/hexo-blog.service:
1 2 3 4 5 6 7 8 9 10 11 12 13
| [Unit] Description=Hexo Blog Server After=network.target
[Service] Type=simple User=root WorkingDirectory=/root/tech-blog/public ExecStart=/usr/bin/python3 -m http.server 8080 Restart=always
[Install] WantedBy=multi-user.target
|
启动服务:
1 2 3
| systemctl daemon-reload systemctl enable hexo-blog systemctl start hexo-blog
|
常见问题
问题 1: Git 克隆失败
症状: 无法访问 github.com
解决:
1 2 3 4 5 6
| cat > ~/.gitconfig << 'EOF' EOF
git clone https://github.com/next-theme/hexo-theme-next themes/next
|
问题 2: 端口被占用
症状: 8080 端口无法启动
解决:
1 2 3 4 5 6 7 8
| netstat -tlnp | grep 8080
kill -9 <PID>
python3 -m http.server 8081
|
问题 3: 防火墙阻止访问
解决:
1 2 3 4 5 6
| firewall-cmd --zone=public --add-port=8080/tcp --permanent firewall-cmd --reload
firewall-cmd --list-ports | grep 8080
|
性能优化
1. 启用缓存
Next 主题支持 PWA 缓存,提升访问速度。
2. 图片优化
使用 WebP 格式,压缩图片大小。
3. CDN 加速
使用 Cloudflare 或阿里云 CDN 加速静态资源。
总结
至此,Hexo 博客已经成功部署在你的 99 元服务器上了!
总成本:
- 服务器:99 元/年
- 域名:可选(约 50 元/年)
- Hexo: 免费
下一步:
- 配置自定义域名
- 申请 HTTPS 证书
- 持续更新内容
参考资源
如有问题,欢迎在评论区留言!