🤖 Ai回答: Setting up a Virtual Private Server (VPS) on Google Cloud Platform (GCP) is straightforward using Google Compute Engine (GCE), which provides scalable virtual machines (VMs) — essentially your VPS.
Here’s a step-by-step guide to create and configure a VPS on Google Cloud:
✅ Step 1: Create a Google Cloud Account
1、Go to [https://cloud.google.com](https://cloud.google.com)
2、Sign in with your Google account.
3、Start a free trial (includes $300 credit for 90 days).
4、Create a new project or use the default one.
✅ Step 2: Enable Billing & APIs
Ensure billing is enabled for your project.
Enable the Compute Engine API:
Go to APIs & Services Library
Search for Compute Engine API → Click Enable
✅ Step 3: Create a Virtual Machine (Your VPS)
Option A: Using Google Cloud Console (Web UI)
1、Go to Compute Engine VM Instances
2、Click Create Instance
3、Configure your VM:
Name: e.g., `my-vps`
Region & Zone: Choose closest to your users (e.g., `us-central1`)
Machine Type:
For basic use: `e2-micro` (eligible for free tier)
Upgrade later if needed
Boot Disk:
Click Change
Choose OS (e.g., Ubuntu 22.04 LTS, Debian, or CentOS)
Size: At least 10 GB (SSD recommended)
Firewall:
☑ Allow HTTP traffic
☑ Allow HTTPS traffic
(Optional) Allow other ports like 22 (SSH), 21 (FTP), etc.
Networking:
Add network tags if needed (e.g., `http-server`, `https-server`)
4、Click Create
⏱️ Your VPS will be ready in ~1 minute.
Option B: Using gcloud CLI (Advanced)
Install the [Google Cloud SDK](https://cloud.google.com/sdk/docs/install), then run:
Option 3: Use External SSH Client (e.g., PuTTY or Terminal)
Get the external IP of your VM from the console.
Generate SSH keys (if not done):
bash
ssh-keygen -t rsa -f ~/.ssh/google_compute_engine
Copy the public key to your VM or use OS Login.
✅ Step 5: Open Ports / Configure Firewall
By default, only SSH (port 22) is open、To allow web traffic:
Create a Firewall Rule:
1、Go to VPC Network Firewall
2、Click Create Firewall Rule
3、Name: `allow-http`
4、Direction: Ingress
5、Targets: All instances in the network (or specific tag like `http-server`)
6、Source IP: `0.0.0.0/0`
7、Protocols and ports: ☑ TCP → Port `80` (and `443` for HTTPS)
8、Click Create
Or via CLI:
bash
gcloud compute firewall-rules create allow-http allow tcp:80 target-tags http-server source-ranges 0.0.0.0/0
By default, your VM has an ephemeral external IP (can change)、To make it permanent:
1、Go to VPC Network External IP addresses
2、Reserve a new Static Address
3、Attach it to your VM instance
✅ Tips & Best Practices
💡 Use labels and names consistently for organization.
🔐 Set up firewall rules conservatively (least privilege).
🔄 Enable automatic updates: `sudo apt install unattended-upgrades`
📦 Use startup scripts for automated setup.
🧯 Take snapshots of disks regularly.
📈 Monitor usage via Cloud Operations (formerly Stackdriver).
💰 Pricing Notes
`e2-micro` VM (1 vCPU, 1 GB RAM): ~$7–10/month (free tier eligible)
Always check the [GCP Pricing Calculator](https://cloud.google.com/products/calculator)
Free tier includes:
1 f1-micro or e2-micro per month (US regions)
30 GB HDD
1 GB network egress
Need Help With?
Let me know what you want to run on your VPS:
Web server (Nginx/Apache)?
Node.js app?
WordPress?
Minecraft server?
Reverse proxy (Nginx/Caddy)?
Docker?