☁️ 如何以 $0 托管你的副项目:终极 GCP 免费层指南
Source: Dev.to

Introduction
Hello, Dev Community! 👋
我很高兴开启一个新系列,届时我将构建一个 AI 驱动的新闻与洞察应用。在我们深入 “Vibe Coding”、大语言模型(LLM)和 Python 脚本之前,需要先为我们的应用找一个落脚点。
虽然 Vercel、Replit 等平台非常棒,但有时你只想要一台原始的 Linux 服务器(VM),以便对环境拥有完整控制——无论是托管 Docker 容器、运行定时任务(cron),还是单纯地玩玩 Linux。
在本指南中,我将手把手教你如何创建一个 Google Cloud Platform (GCP) Compute Engine 实例,使其始终保持在 Always Free 免费层的配额范围内。我会精准标出哪些设置需要调整,以避免意外产生费用!💸
🛠️ Step‑by‑Step Setup
Prerequisites
- 一个已开启计费的 Google Cloud Platform 账户(免费层配额会覆盖费用)。
Step 1: Machine Configuration
-
前往 Compute Engine → Create an instance。
-
Region – 选择一个符合免费层资格的地区:
us-west1、us-east1或us-central1。
我的选择:us-west1(俄勒冈)——对亚洲的延迟稍低。
-
Machine type – 选 e2‑micro(2 vCPU,1 核,1 GB 内存)。

Step 2: OS and Storage (Crucial!)
-
在 “Boot disk” 下点击 Change。
-
Boot disk type: 选择 Standard persistent disk(而非 “Balanced”)。
-
Size: 设置为 30 GB —— 免费层每月包含 30 GB 标准持久磁盘。

Step 3: Data Protection & Observability
-
Backups: 在 “Data protection” 中选择 No backups(快照会产生额外费用)。

-
Observability: 取消勾选 Install Ops Agent —— 在 1 GB
e2‑micro上会占用宝贵的内存。
Step 4: Networking
-
Firewall: 勾选 Allow HTTP traffic 和 Allow HTTPS traffic。

-
展开 Network interfaces 并点击
nic0。
-
Network Service Tier: 将 Premium 改为 Standard(免费/更便宜,适合低使用量)。

📊 Quick Reference: “Golden Config” Decision Table
| Configuration | Default GCP Setting (Costly) | Free‑Tier Choice (Free) | Reason |
|---|---|---|---|
| Region | Local region (varies) | us-west1 (or us-east1 / us-central1) | 只有这些美国地区符合免费层资格 |
| Machine Type | e2‑medium | e2‑micro | 被免费计划覆盖 |
| Disk Type | Balanced Persistent Disk | Standard Persistent Disk | 仅 Standard 包含在 30 GB 免费额度内 |
| Network Tier | Premium | Standard | Premium 会产生每 GB 额外费用 |
| Observability | Ops Agent enabled | Disabled | 为小实例节省 RAM |
✅ Verification
在点击 Create 之前,检查右侧的 Monthly Estimate。它应只显示:
2 vCPU + 1 GB memory30 GB standard persistent disk
如果出现其他项目(例如 “Snapshot schedule” 或 “Ops Agent”),请回到上面的步骤进行调整。

确认无误后,点击 Create!🚀
🔮 What’s Next?
恭喜!你现在拥有一台 每月 $0 的云端 Linux 服务器。
我会把这台 VM 作为即将开展的副项目——AI 新闻与洞察应用——的基础。在后续文章中,我将介绍:
- 在这台 VM 上搭建开发环境
- 使用 “Vibe Coding” 工具生成应用代码
- 将应用部署到这台服务器
**敬请期待系列的下一篇!**如果你有优化免费层 VM 的技巧,欢迎在下方评论分享!👇