白嫖云服务器?其实根本不用 VPS | Free Cloud, No VPS Needed!

想搭建网站、运行 API、体验 Linux,还要免费?其实你可能根本不需要 VPS!利用 GitHub、Google 和 Cloudflare 的免费资源,就能拥有云端开发环境、个人网站和在线 API。MacBook 不必承担所有工作,钱包也终于可以休息一下了。

Want a website, Linux, and your own API without paying for a VPS? You might not need one! GitHub, Google, and Cloudflare provide free tools to build, deploy, and run real projects. Less server spending, more coding, and a very happy wallet!


一、完整实操案例

打造一个免费的个人开发者监控中心。

Build a Free Personal Developer Status Dashboard.

我们将使用免费的云端开发环境,创建一个个人网站、一个在线 API,并通过真实请求验证它们是否正常运行,同时比较传统虚拟主机与 VPS 的区别。
We’ll use free cloud development tools to build a personal website and a live API, test them with real requests, and compare traditional hosting with VPS infrastructure.

最终实现效果

我们创建一个个人网站:

https://your-project.pages.dev

网站展示:

  • Website Status。

  • API Status。

  • Hosting Information。

  • Free Cloud Resources。

  • Last Checked Time。

同时创建一个 API:

https://your-worker.your-subdomain.workers.dev/api/status

返回类似:

{

  "status": "online",

  "service": "personal-dashboard-api",

  "hosting": "cloudflare-workers",

  "free": true

}

这里的域名只是部署成功后生成的示例格式,不是预先存在的真实地址。

最终使用的技术

技术

用途

费用

GitHub

代码管理

免费

GitHub Codespaces

云端开发

免费额度

Google Cloud Shell

Linux 实验

免费额度

Cloudflare Pages

网站托管

免费套餐

Cloudflare Workers

API 服务

免费套餐

HTML / CSS / JavaScript

前端

免费

TypeScript

后端开发

免费

Wrangler

部署工具

开源免费

不使用:

  • 付费 VPS。

  • 付费域名。

  • Docker。

  • 付费 API。

  • OpenAI API。

  • Claude API。

  • 需要信用卡才能启动的付费试用。


二、实际操作步骤

1. 准备 GitHub 账户/Create a GitHub Account

访问 GitHub 注册免费账户。/Create a free GitHub account on GitHub.

https://github.com/

不需要购买 GitHub Pro。/You do not need GitHub Pro.

2. 创建项目/Create the Project

在 GitHub 创建一个公开仓库,名称为 free-cloud-dashboard。/Create a public repository named free-cloud-dashboard.

选择 README 初始化仓库。/Initialize the repository with a README.

3. 启动 Codespaces/Launch Codespaces

进入仓库,选择 Code,再选择 Codespaces,创建新的 Codespace。/Open the repository, select Code, then Codespaces, and create a new Codespace.

选择 2-core 环境,使用免费的个人账户额度。/Choose a 2-core environment and use your personal account’s included free quota.

4. 创建网站文件/Create Website Files

在项目根目录创建 index.html。/Create index.html in the project root.

使用 HTML、CSS 和 JavaScript 创建个人监控页面。/Build the personal dashboard using HTML, CSS, and JavaScript.

页面展示网站状态、API 状态和免费资源信息。/Display website status, API status, and free resource information.

5. 创建 API 项目/Create the API Project

在仓库中创建 api 文件夹。/Create an api directory in the repository.

在 api 目录创建 src/index.ts 和 wrangler.toml。/Create src/index.ts and wrangler.toml inside the api directory.

使用 TypeScript 编写一个 GET API,访问 /api/status 时返回 JSON。/Use TypeScript to create a GET API that returns JSON when /api/status is requested.

6. 安装 Wrangler/Install Wrangler

在 Codespaces 终端运行 npm init -y。/Run npm init -y in the Codespaces terminal.

运行 npm install -D wrangler typescript。/Run npm install -D wrangler typescript.

Wrangler 是 Cloudflare 官方提供的开发和部署工具。/Wrangler is Cloudflare’s official development and deployment tool.

7. 配置 API/Configure the API

在 api/src/index.ts 中创建 GET 请求处理程序。/Create a GET request handler in api/src/index.ts.

让 API 返回 status、service、hosting 和 free 四个字段。/Make the API return four fields: status, service, hosting, and free.

8. 创建 Cloudflare 账户/Create a Cloudflare Account

访问 Cloudflare 官网,注册免费账户。/Visit Cloudflare and create a free account.

https://dash.cloudflare.com/

选择 Free 套餐,不启用付费服务。/Select the Free plan without enabling paid services.

9. 部署 Workers API/Deploy the Workers API

进入 Cloudflare Workers,创建新的 Worker。/Open Cloudflare Workers and create a new Worker.

使用 Wrangler 登录并部署 API。/Authenticate with Wrangler and deploy the API.

部署成功后,获得 workers.dev 地址。/After deployment, obtain your workers.dev URL.

10. 测试 API/Test the API

在浏览器打开 API 地址。/Open the API URL in your browser.

访问 /api/status,确认返回 JSON 和 online 状态。/Visit /api/status and confirm that the API returns JSON with an online status.

也可以使用 curl 测试。/You can also test it using curl.

curl https://your-worker.your-subdomain.workers.dev/api/status

11. 部署 Cloudflare Pages/Deploy Cloudflare Pages

进入 Cloudflare Dashboard,选择 Workers & Pages。/Open Cloudflare Dashboard and select Workers & Pages.

创建 Pages 项目并连接 GitHub 仓库。/Create a Pages project and connect your GitHub repository.

选择对应分支,配置网站根目录和部署设置。/Select the appropriate branch and configure the website root directory and deployment settings.

对于这个纯 HTML 项目,Build command 留空,输出目录填写项目根目录。/For this plain HTML project, leave the build command empty and set the output directory to the repository root.

12. 获得免费网站地址/Get Your Free Website URL

等待 Cloudflare 完成部署。/Wait for Cloudflare to finish deployment.

成功后获得 pages.dev 免费域名。/After successful deployment, you receive a free pages.dev domain.

使用浏览器打开网站。/Open the website in your browser.

13. 连接网站和 API/Connect the Website to the API

修改 index.html 中的 API 地址。/Update the API URL in index.html.

使用 JavaScript fetch 请求 API。/Use JavaScript fetch to call the API.

将返回的 online 状态显示在网页上。/Display the returned online status on the website.

14. 使用 GitHub 自动部署/Enable Automatic Deployment

修改 index.html 中的文字或样式。/Change the text or styling in index.html.

执行 git add、git commit 和 git push。/Run git add, git commit, and git push.

Cloudflare Pages 自动检测 GitHub 更新并重新部署。/Cloudflare Pages automatically detects GitHub changes and redeploys the website.

15. 使用 Google Cloud Shell/Use Google Cloud Shell

打开 Google Cloud Shell。/Open Google Cloud Shell.

https://shell.cloud.google.com/

运行:

uname -a

node --version

python3 --version

git --version

观察 Linux 环境、Node.js、Python 和 Git 版本。/Inspect the Linux environment and the Node.js, Python, and Git versions.

这一步演示的是云端 Linux 开发环境,不是 VPS。/This demonstrates a cloud Linux development environment, not a VPS.

16. 体验传统免费虚拟主机/Try Traditional Free Web Hosting

注册 GoogieHost 免费账户。/Register for a free GoogieHost account.

https://googiehost.com/freehosting

进入 DirectAdmin,查看文件管理、MySQL、FTP 和 WordPress 安装功能。/Open DirectAdmin and explore file management, MySQL, FTP, and WordPress installation.

可以额外部署一个简单的 PHP 页面,对比传统虚拟主机和 Cloudflare Pages。/Optionally deploy a simple PHP page to compare traditional shared hosting with Cloudflare Pages.

17. 对比 VPS 与 Serverless/Compare VPS and Serverless

展示传统 VPS 的 Linux、SSH、Root、Docker 和后台进程管理能力。/Demonstrate the Linux, SSH, Root, Docker, and background-process capabilities of a traditional VPS.

再展示 Cloudflare Workers 如何运行 HTTP API,而不需要自行维护 Linux 服务器。/Then demonstrate how Cloudflare Workers runs an HTTP API without requiring you to maintain a Linux server.

强调 Workers 不是 VPS,不能替代所有服务器工作负载。/Emphasise that Workers is not a VPS and cannot replace every server workload.

18. 验证免费额度/Verify Free Usage Limits

打开 GitHub Codespaces 使用量页面,检查剩余 Core Hours 和存储额度。/Open GitHub Codespaces usage settings and check the remaining Core Hours and storage quota.

检查 Cloudflare Workers 的每日请求额度和 Pages 的每月构建额度。/Check Cloudflare Workers’ daily request allowance and Pages’ monthly build allowance.

确认所有项目均处于免费套餐。/Confirm that all services remain on their Free plans.

19. 最终测试与总结/Final Testing and Review

同时打开网站和 API 地址。/Open the website and API endpoints.

验证网页能够正常加载,API 能够正常返回 JSON。/Verify that the website loads and the API returns valid JSON.

最后总结:网站托管、云端开发和 VPS 是三种不同需求,不必为了运行一个小型 API 就购买 VPS。/Conclude that website hosting, cloud development, and VPS infrastructure solve different problems, and a small API does not automatically require a VPS.


相关链接/Related Links
https://github.com/
https://github.com/features/codespaces
https://docs.github.com/en/codespaces
https://cloud.google.com/
https://shell.cloud.google.com/
https://docs.cloud.google.com/shell/docs
https://colab.research.google.com/
https://research.google.com/colaboratory/
https://www.kaggle.com/
https://www.kaggle.com/docs/notebooks
https://googiehost.com/
https://googiehost.com/freehosting
https://googiehost.com/terms
https://www.cloudflare.com/
https://dash.cloudflare.com/
https://developers.cloudflare.com/pages/
https://developers.cloudflare.com/workers/
https://github.com/cloudflare/workers-sdk
https://developers.cloudflare.com/pages/platform/limits/
https://developers.cloudflare.com/workers/platform/limits/

评论

爽文共赏/Popular Posts

5分钟拿下原生IP + 免费节点 手残变大佬 | From Noob to Pro in 5 Minutes: 10 Real IPs + Daily Fresh Free Nodes

一口气搭好!Cloudflare融合Railway与Galaxy打造纯净原生免费VPS | Build a Pure Free VPS with Cloudflare + Railway + Galaxy in One Go

免费节点无限续?OneBox+subs-check,付费党沉默了 | Free Nodes Never Die? OneBox + subs-check, Paid Users Left Speechless

3 Steps to AI Video Fame✨WebSocket+Copilot Auto-Update, Newbies Win Too | 3 步 AI 视频封神✨WebSocket+Copilot 自动更,小白也能卷赢

Game-Changing! Get AI Parenting+Math Enlightenment for Free | 0成本get AI育儿+数学启蒙双buff,躺赢养娃

零成本薅云服务器 | 三分钟开人生外挂 ⚡ | Zero-Cost Cloud Hustle | Life Cheat Code for Broke Devs 🍜