Modul praktis Level 2 VibeKoding: Rilis Tingkat Lanjut: Setup Server VPS Linux.Modul praktis Level 2 VibeKoding: Rilis Tingkat Lanjut: Setup Server VPS Linux.
import RelatedArticlesSection from '../../../../.vitepress/theme/components/RelatedArticlesSection.vue'import RelatedArticlesSection from '../../../../.vitepress/theme/components/RelatedArticlesSection.vue'
import { relatedArticlesMap } from '../../../../.vitepress/theme/data/relatedArticles'import { relatedArticlesMap } from '../../../../.vitepress/theme/data/relatedArticles'
> ๐ก What does "putting a website online" mean? Also called "going live" or "deploying/publishing". A website you built on your own computer can only be opened by you. Putting it online means placing it on a server that runs 24/7, so anyone can type a URL in their browser and visit it โ just like a Word doc only you can read becomes visible to everyone once you post it to a blog; the difference is that this time you're publishing a full website.> ๐ก What does "putting a website online" mean? Also called "going live" or "deploying/publishing". A website you built on your own computer can only be opened by you. Putting it online means placing it on a server that runs 24/7, so anyone can type a URL in their browser and visit it โ just like a Word doc only you can read becomes visible to everyone once you post it to a blog; the difference is that this time you're publishing a full website.
In the previous chapter we learned the easiest way to publish โ using one-click PaaS platforms like Vercel or Zeabur. This chapter covers the more flexible, do-it-yourself approach: buy your own cloud server, set everything up from scratch, and publish your site yourself. You'll learn how to pick a server, connect to it, install the environment, configure Nginx, attach a domain, and enable HTTPS. Once you understand this, no platform can limit you โ run whatever services you want.In the previous chapter we learned the easiest way to publish โ using one-click PaaS platforms like Vercel or Zeabur. This chapter covers the more flexible, do-it-yourself approach: buy your own cloud server, set everything up from scratch, and publish your site yourself. You'll learn how to pick a server, connect to it, install the environment, configure Nginx, attach a domain, and enable HTTPS. Once you understand this, no platform can limit you โ run whatever services you want.
------
Before picking a platform, answer three questions:Before picking a platform, answer three questions:
CODE What type of project are you deploying? โ โโ Pure frontend static site (Vite/React/Vue build output) โ โโ Completely free โ Cloudflare Pages (unlimited bandwidth) / GitHub Pages โ โโ Next.js project โ Vercel (official platform, best DX) โ โโ China users primarily โ Cloudflare Pages or domestic OSS+CDN โ โโ Backend API, doesn't need to be always-on (request-triggered) โ โโ Node.js/Python API โ Vercel Functions / Cloudflare Workers โ โโ Full-stack frameworks (Next.js/Nuxt/SvelteKit) โ Vercel โ โโ Needs always-on process (Bot, cron, WebSocket) โ โโ Don't want to manage servers โ Railway / Render / Fly.io โ โโ Full control & cost savings โ Buy a VPS (DigitalOcean / Vultr / Hetzner / AWS EC2) โ โโ China-facing projects โ Tencent Cloud Lighthouse / Alibaba Cloud ECS โ โโ Need to run AI models / GPU โ โโ Inference API โ Modal / Replicate / Hugging Face Inference โ โโ Training/Fine-tuning โ Modal / Lambda Labs โ โโ China GPU โ AutoDL / Alibaba Cloud PAI โ โโ Large production projects โโ AWS/GCP + Kubernetes (hire DevOps or let AI write Terraform)
------
For most personal projects, demos, and portfolios, you don't need to buy a server at all. This section covers the most popular free/low-cost platforms with how to sign up, how to use them, and their gotchas.For most personal projects, demos, and portfolios, you don't need to buy a server at all. This section covers the most popular free/low-cost platforms with how to sign up, how to use them, and their gotchas.
Website: https://vercel.comWebsite: https://vercel.com
Best for: Next.js projects, React/Vue frontends, full-stack apps with Serverless Functions, AI chatbots (fast response time)Best for: Next.js projects, React/Vue frontends, full-stack apps with Serverless Functions, AI chatbots (fast response time)
How to use:How to use:
xxx.vercel.appClick "Deploy" โ your site is live in 1-2 minutes at xxx.vercel.appFree tier (Hobby plan):Free tier (Hobby plan):
Paid (Pro, $20/month):Paid (Pro, $20/month):
โ ๏ธ Key limitations beginners hit:โ ๏ธ Key limitations beginners hit:
Verdict: Vercel is the smoothest experience for deploying frontend pages, docs, and quick demos. But for always-on agents or long-running AI calls โ don't use Vercel.Verdict: Vercel is the smoothest experience for deploying frontend pages, docs, and quick demos. But for always-on agents or long-running AI calls โ don't use Vercel.
Website: https://pages.cloudflare.comWebsite: https://pages.cloudflare.com
Best for: Static sites, bandwidth-heavy projects, global audiences, Edge FunctionsBest for: Static sites, bandwidth-heavy projects, global audiences, Edge Functions
Free tier:Free tier:
How to use:How to use:
npm run build, output dir: dist)Select your repo, set build command (Vite: npm run build, output dir: dist)Bonus: Workers AI: Cloudflare also offers running open-source AI models (Llama 3, Mistral, Stable Diffusion) on edge nodes, with 10,000 neurons/day free. Great for running small models without relying on OpenAI APIs.Bonus: Workers AI: Cloudflare also offers running open-source AI models (Llama 3, Mistral, Stable Diffusion) on edge nodes, with 10,000 neurons/day free. Great for running small models without relying on OpenAI APIs.
Verdict: Best choice for static sites, especially projects with global audiences. Unlimited bandwidth is a killer feature.Verdict: Best choice for static sites, especially projects with global audiences. Unlimited bandwidth is a killer feature.
Website: https://railway.appWebsite: https://railway.app
Best for: Always-on backend services, Node.js/Python/Go APIs, Discord/Telegram bots, full-stack projects needing databasesBest for: Always-on backend services, Node.js/Python/Go APIs, Discord/Telegram bots, full-stack projects needing databases
How to use:How to use:
Pricing:Pricing:
Verdict: Railway has the best experience for deploying backend APIs, bots, and full-stack apps needing databases โ auto-deploy from GitHub, built-in databases, logs and monitoring all included.Verdict: Railway has the best experience for deploying backend APIs, bots, and full-stack apps needing databases โ auto-deploy from GitHub, built-in databases, logs and monitoring all included.
Website: https://fly.ioWebsite: https://fly.io
Best for: Low-latency globally distributed services, wanting a truly free 24/7 container, accepting a slight learning curveBest for: Low-latency globally distributed services, wanting a truly free 24/7 container, accepting a slight learning curve
Free tier:Free tier:
How to use:How to use:
fly.toml config in your project (AI can generate this)Write a fly.toml config in your project (AI can generate this)fly launch โ auto-builds Docker image, allocates IP, deploysfly launch โ auto-builds Docker image, allocates IP, deploysfly deploy to update, fly logs to view logsfly deploy to update, fly logs to view logsVerdict: If you need a truly 24/7 free container for a bot/API/cron job, Fly.io is the best free option. Trade-off is learning flyctl commands and Docker basics.Verdict: If you need a truly 24/7 free container for a bot/API/cron job, Fly.io is the best free option. Trade-off is learning flyctl commands and Docker basics.
Website: https://render.comWebsite: https://render.com
Best for: Learning phase, personal projects, projects that don't mind cold startsBest for: Learning phase, personal projects, projects that don't mind cold starts
Free tier:Free tier:
โ ๏ธ Key issue:โ ๏ธ Key issue:
Verdict: Good for dev/testing/school projects, but don't put production user-facing projects on the free tier. Paid starts at $7/month to disable sleeping.Verdict: Good for dev/testing/school projects, but don't put production user-facing projects on the free tier. Paid starts at $7/month to disable sleeping.
| Platform | Type | Free Tier | Highlights |
|---|---|---|---|
| GitHub Pages | Static hosting | Unlimited (100GB soft limit) | Easiest: push to GitHub, it goes live |
| Hugging Face Spaces | AI apps | Free CPU small instance | Dedicated to AI demos (Gradio/Streamlit) |
| Modal | AI/Serverless GPU | $30/month credit | Python functions-as-a-service, GPU cold start <4s |
| Replicate | AI model hosting | Pay per call | Turn models into APIs without infra management |
| Denoland Deploy | Deno/Edge | 100k requests/day free | Deno official platform, native TypeScript |
| Netlify | Static hosting | 100GB bandwidth/month | Rich plugin ecosystem |
| Supabase | BaaS | 500MB DB free | Open-source Firebase alternative, Postgres+Auth+Storage |
| Neon | Serverless Postgres | 500MB free | Branchable databases for Serverless |
| Upstash | Serverless Redis | 10k commands/day free | Request-based Redis for Serverless |
------
If you need full control over the server environment, run custom services, or PaaS doesn't cover your needs, it's time to buy your own cloud server. This section walks through AWS (the most widely used global cloud platform), and also covers alternatives like DigitalOcean, Vultr, and Hetzner.If you need full control over the server environment, run custom services, or PaaS doesn't cover your needs, it's time to buy your own cloud server. This section walks through AWS (the most widely used global cloud platform), and also covers alternatives like DigitalOcean, Vultr, and Hetzner.
AWS offers new users a 12-month Free Tier that's perfect for learning and personal projects. Here's what's included:AWS offers new users a 12-month Free Tier that's perfect for learning and personal projects. Here's what's included:
| Service | Free Tier Allocation |
|---|---|
| EC2 | 750 hours/month of t2.micro or t3.micro (one instance running 24/7) |
| S3 | 5GB standard storage |
| RDS | 750 hours/month db.t2.micro/db.t3.micro + 20GB storage |
| Lambda | 1 million requests/month + 3.2 million seconds compute |
| CloudFront | 50GB egress + 2 million requests/month |
| CloudWatch | 10 custom metrics + 1GB log ingestion |
| DynamoDB | 25GB storage + 2.5 million read/write capacity units |
โ ๏ธ Important: Free Tier expires 12 months after sign-up, after which you'll be charged standard rates. Always set up billing alerts (Billing Dashboard โ Budgets) to avoid surprise charges. Destroy resources you're not using!โ ๏ธ Important: Free Tier expires 12 months after sign-up, after which you'll be charged standard rates. Always set up billing alerts (Billing Dashboard โ Budgets) to avoid surprise charges. Destroy resources you're not using!
my-aws-key.pem), download it, and store it safely. You cannot download it again!Key Pair: When prompted, create a new key pair (e.g. my-aws-key.pem), download it, and store it safely. You cannot download it again!bash # On your local Mac/Linux terminal chmod 400 my-aws-key.pem # Set correct permissions (required!) ssh -i my-aws-key.pem ubuntu@YOUR_PUBLIC_IP # e.g. ssh -i my-aws-key.pem ubuntu@54.123.45.67 # On Windows use PuTTY (convert .pem to .ppk) or Windows Terminal with OpenSSH
Get your public IP: Go to EC2 Dashboard โ Instances โ Select your instance โ Look for "Public IPv4 address" in the details.Get your public IP: Go to EC2 Dashboard โ Instances โ Select your instance โ Look for "Public IPv4 address" in the details.
Website: https://www.digitalocean.comWebsite: https://www.digitalocean.com
Pricing: Droplets start at $4/month (512MB RAM, 10GB SSD, 500GB bandwidth)Pricing: Droplets start at $4/month (512MB RAM, 10GB SSD, 500GB bandwidth)
Why choose DO: Their documentation (called "community tutorials") is legendary โ almost any Linux/server question has a well-written DO tutorial. Their interface is clean and beginner-friendly.Why choose DO: Their documentation (called "community tutorials") is legendary โ almost any Linux/server question has a well-written DO tutorial. Their interface is clean and beginner-friendly.
How to use:How to use:
ssh root@YOUR_DROPLET_IPConnect via: ssh root@YOUR_DROPLET_IPWebsite: https://www.vultr.comWebsite: https://www.vultr.com
Pricing: Regular Cloud Compute starts at $5/month (1 vCPU, 1GB RAM, 25GB SSD, 1TB bandwidth)Pricing: Regular Cloud Compute starts at $5/month (1 vCPU, 1GB RAM, 25GB SSD, 1TB bandwidth)
Why choose Vultr: Pay by the hour (you can spin up a server for 10 minutes to test something, then destroy it and pay cents), 30+ global locations, and they have affordable GPU instances if you need that later.Why choose Vultr: Pay by the hour (you can spin up a server for 10 minutes to test something, then destroy it and pay cents), 30+ global locations, and they have affordable GPU instances if you need that later.
Website: https://www.hetzner.com/cloudWebsite: https://www.hetzner.com/cloud
Pricing: CX11 starts at โฌ3.49/month (1 vCPU, 2GB RAM, 20GB SSD, 20TB traffic!)Pricing: CX11 starts at โฌ3.49/month (1 vCPU, 2GB RAM, 20GB SSD, 20TB traffic!)
Why choose Hetzner: Best price-to-performance ratio in Europe, extremely stable network. Great for long-running production projects. The tradeoff is datacenters are in Germany/Finland/US (no Asia locations).Why choose Hetzner: Best price-to-performance ratio in Europe, extremely stable network. Great for long-running production projects. The tradeoff is datacenters are in Germany/Finland/US (no Asia locations).
| Provider | Starting Price | Best For | Free Trial |
|---|---|---|---|
| AWS EC2 | Free tier for 12 months, then ~$10/month | Learning AWS, enterprise integration | 12 months Free Tier |
| DigitalOcean | $4/month | Beginners, great docs | $200 credit for 60 days (new users) |
| Vultr | $5/month ($2.50 for IPv6-only) | Hourly testing, many regions | $100 credit for 30 days |
| Hetzner | โฌ3.49/month | Best value long-term projects | โฌ20 credit |
| Linode (Akamai) | $5/month | Established, reliable | $100 credit for 60 days |
------
Once you've SSH'd into your server, the first thing is to update the system and install basic tools. You can copy the prompt below to your AI assistant and let it generate the exact commands you need:Once you've SSH'd into your server, the first thing is to update the system and install basic tools. You can copy the prompt below to your AI assistant and let it generate the exact commands you need:
> "I just set up a new Ubuntu 22.04 server and want to deploy a [Node.js/Python/...] project. Give me the complete initialization commands including: system update, create a non-root sudo user, configure SSH key auth, install Node.js 20, install Nginx, install Docker, configure basic ufw firewall."> "I just set up a new Ubuntu 22.04 server and want to deploy a [Node.js/Python/...] project. Give me the complete initialization commands including: system update, create a non-root sudo user, configure SSH key auth, install Node.js 20, install Nginx, install Docker, configure basic ufw firewall."
A typical initial setup:A typical initial setup:
bash # 1. Update system and install basic tools sudo apt update && sudo apt upgrade -y sudo apt install -y curl wget git vim ufw build-essential # 2. Create a regular user (don't always use root!) sudo adduser yourname sudo usermod -aG sudo yourname # 3. Install Node.js (use nvm, NOT apt) curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash source ~/.bashrc nvm install 20 node -v # verify # 4. Install Nginx sudo apt install -y nginx sudo systemctl start nginx sudo systemctl enable nginx # Visit http://YOUR-IP in browser, should see Nginx welcome page # 5. Install Docker (if using containers) curl -fsSL https://get.docker.com | sh sudo usermod -aG docker yourname # run Docker without sudo # Log out and back in for this to take effect docker --version # 6. Configure firewall sudo ufw allow ssh sudo ufw allow http sudo ufw allow https sudo ufw enable sudo ufw status
On AWS this is done via Security Groups (in the EC2 console). On DigitalOcean/Vultr it's in their dashboard firewall settings. On Ubuntu you also need ufw.On AWS this is done via Security Groups (in the EC2 console). On DigitalOcean/Vultr it's in their dashboard firewall settings. On Ubuntu you also need ufw.
Open these ports at minimum:Open these ports at minimum:
| Port | Purpose | Recommendation |
|---|---|---|
| 22 | SSH | Required; restrict to your IP if possible |
| 80 | HTTP | Required for web |
| 443 | HTTPS | Required for secure web |
| 3000-3999 | Node.js dev ports | Open temporarily for debugging, close after deployment |
> โ ๏ธ #1 beginner mistake: The app is running but you can't access it. 90% of the time it's because the security group/firewall isn't allowing that port.> โ ๏ธ #1 beginner mistake: The app is running but you can't access it. 90% of the time it's because the security group/firewall isn't allowing that port.
------
After npm run build, you get a dist/ folder with pure HTML/CSS/JS files.After npm run build, you get a dist/ folder with pure HTML/CSS/JS files.
Get code to the server:Get code to the server:
bash # Option A: rsync from local machine rsync -avz --exclude=node_modules ./dist/ yourname@YOUR-IP:/var/www/myapp/ # Option B: git clone on server (recommended, easier updates) cd /var/www sudo git clone https://github.com/YOUR_USER/YOUR_REPO.git myapp cd myapp npm install npm run build
Configure Nginx:Configure Nginx:
bash sudo vim /etc/nginx/sites-available/myapp
nginx server { listen 80; server_name YOUR-IP-OR-DOMAIN; root /var/www/myapp/dist; index index.html; location / { try_files $uri $uri/ /index.html; # SPA routing fallback } location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2?)$ { expires 1y; add_header Cache-Control "public, immutable"; } }
Enable the site:Enable the site:
bash sudo ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/ sudo nginx -t && sudo systemctl reload nginx
Use PM2 to keep the app running in the background:Use PM2 to keep the app running in the background:
bash npm install -g pm2 cd /path/to/your/app npm install npm run build # if TypeScript pm2 start dist/main.js --name "myapp" pm2 startup && pm2 save # auto-start on boot pm2 logs myapp # view logs
Nginx reverse proxy:Nginx reverse proxy:
nginx server { listen 80; server_name api.yourdomain.com; location / { proxy_pass http://127.0.0.1:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } }
yaml # docker-compose.yml version: '3.8' services: app: build: . ports: - "3000:3000" environment: - DATABASE_URL=postgresql://postgres:pass@db:5432/myapp depends_on: [db, redis] restart: always db: image: postgres:16-alpine environment: POSTGRES_PASSWORD: pass POSTGRES_DB: myapp volumes: - postgres_data:/var/lib/postgresql/data restart: always redis: image: redis:7-alpine restart: always nginx: image: nginx:alpine ports: - "80:80" - "443:443" volumes: - ./nginx.conf:/etc/nginx/conf.d/default.conf - ./frontend/dist:/usr/share/nginx/html depends_on: [app] restart: always volumes: postgres_data:
Run with: docker compose up -dRun with: docker compose up -d
------
Register a domain via Namecheap, Cloudflare Registrar, GoDaddy, or AWS Route 53. In your domain's DNS settings, add A records:Register a domain via Namecheap, Cloudflare Registrar, GoDaddy, or AWS Route 53. In your domain's DNS settings, add A records:
| Type | Host | Value |
|---|---|---|
| A | @ | Your server IP |
| A | www | Your server IP |
| A | api | Your server IP (for backend) |
bash sudo apt install -y certbot python3-certbot-nginx sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com -d api.yourdomain.com # Choose option 2 (Redirect) to auto-redirect HTTP to HTTPS sudo certbot renew --dry-run # test auto-renewal
------
When you log into AWS Console (or any cloud dashboard), you'll see dozens of services with cryptic names (EC2, S3, RDS, ELB, VPCโฆ). This section explains the most common ones and when to use them, using AWS as the primary example (the concepts map directly to other clouds).When you log into AWS Console (or any cloud dashboard), you'll see dozens of services with cryptic names (EC2, S3, RDS, ELB, VPCโฆ). This section explains the most common ones and when to use them, using AWS as the primary example (the concepts map directly to other clouds).
A typical web application running on the cloud looks like this:A typical web application running on the cloud looks like this:
CODE User โ CloudFront (CDN) โ ALB (Load Balancer) โ EC2 (Your App Server) โ โ โ โโโ S3 (images/files) โ โโโ RDS (database) โ โโโ ElastiCache (Redis) โ โโโ ECS/EKS (containers, advanced) โโโ Route 53 (DNS) โ maps your domain to CloudFront/ALB + ACM (SSL certs) โ HTTPS encryption
Let's go through each service.Let's go through each service.
This is the "cloud server" we've been using. It's a virtual machine you can SSH into, install anything on, and configure however you want.This is the "cloud server" we've been using. It's a virtual machine you can SSH into, install anything on, and configure however you want.
When to use: When you need full control, custom software, always-on processes.When to use: When you need full control, custom software, always-on processes.
Upload code snippets without managing servers. Pay per invocation and execution time. Runs only when triggered.Upload code snippets without managing servers. Pay per invocation and execution time. Runs only when triggered.
When to use: Occasional tasks (webhook handlers, image processing, scheduled jobs), APIs with spiky traffic. Not for always-on processes like WebSocket bots.When to use: Occasional tasks (webhook handlers, image processing, scheduled jobs), APIs with spiky traffic. Not for always-on processes like WebSocket bots.
If your project uses Docker and grows to multiple containers/services, use Kubernetes for orchestration.If your project uses Docker and grows to multiple containers/services, use Kubernetes for orchestration.
When to use: Multi-service microservice architectures, auto-scaling, team projects. Most personal projects won't need this โ a VPS + Docker Compose is enough.When to use: Multi-service microservice architectures, auto-scaling, team projects. Most personal projects won't need this โ a VPS + Docker Compose is enough.
This is the most common service beyond servers, used for storing images, videos, PDFs, static site assets, backups, and more. Never store user-uploaded files on your server's local disk! They'll be lost if you rebuild/migrate/resize the server.This is the most common service beyond servers, used for storing images, videos, PDFs, static site assets, backups, and more. Never store user-uploaded files on your server's local disk! They'll be lost if you rebuild/migrate/resize the server.
Free tier: AWS S3 gives 5GB standard storage for 12 months under Free Tier. Alibaba Cloud OSS gives new users 5GB for 6 months. Cloudflare R2 has a permanent free tier with 10GB storage.Free tier: AWS S3 gives 5GB standard storage for 12 months under Free Tier. Alibaba Cloud OSS gives new users 5GB for 6 months. Cloudflare R2 has a permanent free tier with 10GB storage.
What you can do with S3:What you can do with S3:
dist/ folder, enable "Static website hosting")Host static websites (upload your dist/ folder, enable "Static website hosting")How to use S3 (AWS Console walkthrough):How to use S3 (AWS Console walkthrough):
myapp-images)Enter a globally unique bucket name (e.g. myapp-images)https://myapp-images.s3.us-east-1.amazonaws.com/avatar.jpgAfter upload, each file gets a URL like https://myapp-images.s3.us-east-1.amazonaws.com/avatar.jpg
Use that URL directly in your frontend 
Using S3 with code (Node.js example, ask AI to write the full logic):Using S3 with code (Node.js example, ask AI to write the full logic):
javascript // npm install @aws-sdk/client-s3 @aws-sdk/lib-storage import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3"; const s3 = new S3Client({ region: "us-east-1" }); async function uploadFile(buffer, filename, contentType) { await s3.send(new PutObjectCommand({ Bucket: "myapp-images", Key: filename, Body: buffer, ContentType: contentType, ACL: "public-read" // make file publicly accessible })); return `https://myapp-images.s3.us-east-1.amazonaws.com/${filename}`; }
> โ ๏ธ Critical Security Note: AWS Access Keys are like your S3 password. Never hardcode them in frontend code or commit to Git! Store them in environment variables or use IAM roles. If keys leak, disable them immediately in IAM console.> โ ๏ธ Critical Security Note: AWS Access Keys are like your S3 password. Never hardcode them in frontend code or commit to Git! Store them in environment variables or use IAM roles. If keys leak, disable them immediately in IAM console.
Block storage volumes attached to EC2 instances (like your computer's hard drive). EC2 instances come with a root volume (8-60GB typically); buy additional EBS volumes when you need more space.Block storage volumes attached to EC2 instances (like your computer's hard drive). EC2 instances come with a root volume (8-60GB typically); buy additional EBS volumes when you need more space.
When to use: Extra disk space for your server, data that needs to persist independently of the EC2 instance lifecycle.When to use: Extra disk space for your server, data that needs to persist independently of the EC2 instance lifecycle.
A network file system that multiple EC2 instances can mount simultaneously. Good for sharing uploaded files across multiple web servers.A network file system that multiple EC2 instances can mount simultaneously. Good for sharing uploaded files across multiple web servers.
Most small projects don't need this โ a single server + S3 is enough.Most small projects don't need this โ a single server + S3 is enough.
Don't run your production database on the same VPS! While technically possible (we did this earlier in the Docker Compose example), for production use a managed database: automated backups, high availability, monitoring, and one-click scaling.Don't run your production database on the same VPS! While technically possible (we did this earlier in the Docker Compose example), for production use a managed database: automated backups, high availability, monitoring, and one-click scaling.
Supported engines: MySQL, PostgreSQL, MariaDB, SQL Server, Oracle, and Amazon Aurora (MySQL/PostgreSQL-compatible, cloud-optimized).Supported engines: MySQL, PostgreSQL, MariaDB, SQL Server, Oracle, and Amazon Aurora (MySQL/PostgreSQL-compatible, cloud-optimized).
Free tier: AWS RDS gives 750 hours/month of db.t2.micro or db.t3.micro + 20GB storage for 12 months.Free tier: AWS RDS gives 750 hours/month of db.t2.micro or db.t3.micro + 20GB storage for 12 months.
How to set up RDS (AWS):How to set up RDS (AWS):
mydb.xxxxx.us-east-1.rds.amazonaws.com:3306)Once available, get the Endpoint (looks like mydb.xxxxx.us-east-1.rds.amazonaws.com:3306)DATABASE_URL to point to this endpoint, and add your EC2 security group to the RDS security group's inbound rulesUpdate your app's DATABASE_URL to point to this endpoint, and add your EC2 security group to the RDS security group's inbound rules> ๐ก vibecoding tip: Tell AI "I have an AWS RDS PostgreSQL instance at [endpoint], with user [username], help me write connection code and migration scripts for [my project]."> ๐ก vibecoding tip: Tell AI "I have an AWS RDS PostgreSQL instance at [endpoint], with user [username], help me write connection code and migration scripts for [my project]."
In-memory caching for hot data (reducing DB queries), session/token storage, message queues, leaderboards, etc.In-memory caching for hot data (reducing DB queries), session/token storage, message queues, leaderboards, etc.
For small projects you can just run sudo apt install redis-server on your VPS; use managed Redis for production/high availability.For small projects you can just run sudo apt install redis-server on your VPS; use managed Redis for production/high availability.
Caches your static assets (images, CSS, JS, video) at edge locations worldwide so users get content from the nearest node.Caches your static assets (images, CSS, JS, video) at edge locations worldwide so users get content from the nearest node.
When to use:When to use:
How to configure CloudFront:How to configure CloudFront:
dxxx.cloudfront.net) via a CNAME recordPoint your domain's DNS to the CloudFront distribution domain name (e.g. dxxx.cloudfront.net) via a CNAME recordDistributes incoming traffic across multiple EC2 instances, automatically removing unhealthy instances.Distributes incoming traffic across multiple EC2 instances, automatically removing unhealthy instances.
Single-server projects don't need this. Use it when you scale to multiple backend servers.Single-server projects don't need this. Use it when you scale to multiple backend servers.
Translates domain names to IP addresses. Most domain registrars include free DNS, but Route 53 is deeply integrated with AWS.Translates domain names to IP addresses. Most domain registrars include free DNS, but Route 53 is deeply integrated with AWS.
Common DNS record types:Common DNS record types:
| Type | Purpose | Example |
|---|---|---|
| A | Domain โ IPv4 address | @ โ 54.123.45.67 |
| AAAA | Domain โ IPv6 address | @ โ 2600:xxxx:: |
| CNAME | Domain โ another domain (used for CDN) | static โ dxxx.cloudfront.net |
| MX | Mail server (needed for business email) | - |
| TXT | Arbitrary text (domain verification, SPF/DKIM) | - |
AWS provides free SSL/TLS certificates that auto-renew when used with CloudFront or ALB. Just request a certificate, validate via DNS or email, and attach it to your distribution/load balancer.AWS provides free SSL/TLS certificates that auto-renew when used with CloudFront or ALB. Just request a certificate, validate via DNS or email, and attach it to your distribution/load balancer.
An isolated virtual network on AWS where your EC2, RDS, and other resources live. New accounts get a default VPC. Advanced usage (public/private subnet separation, NAT gateways) requires deeper study.An isolated virtual network on AWS where your EC2, RDS, and other resources live. New accounts get a default VPC. Advanced usage (public/private subnet separation, NAT gateways) requires deeper study.
Don't run your own mail server (you'll likely end up in spam). Use a professional email service.Don't run your own mail server (you'll likely end up in spam). Use a professional email service.
For SMS, mobile push notifications. Twilio is the popular global alternative for SMS.For SMS, mobile push notifications. Twilio is the popular global alternative for SMS.
Monitor EC2 CPU/memory/disk, view application logs, set up alerts (high CPU, service down).Monitor EC2 CPU/memory/disk, view application logs, set up alerts (high CPU, service down).
S3 can automatically trigger Lambda functions when files are uploaded. For example, when a user uploads a large photo, a Lambda function can resize it into thumbnails automatically. In China, Alibaba OSS has built-in image processing (append ?x-oss-process=image/resize,w_300 to URLs) and Tencent COS has Cloud Infinite (CI) for similar features.S3 can automatically trigger Lambda functions when files are uploaded. For example, when a user uploads a large photo, a Lambda function can resize it into thumbnails automatically. In China, Alibaba OSS has built-in image processing (append ?x-oss-process=image/resize,w_300 to URLs) and Tencent COS has Cloud Infinite (CI) for similar features.
Quick reference for finding equivalent services:Quick reference for finding equivalent services:
| Category | AWS | Alibaba Cloud | Tencent Cloud | Free/Budget Alternative |
|---|---|---|---|---|
| Cloud Servers | EC2 | ECS | CVM / Lighthouse | DigitalOcean / Vultr / Hetzner |
| Object Storage | S3 | OSS | COS | Cloudflare R2 (zero egress) |
| Relational DB | RDS | RDS | TDSQL-C/CDB | Supabase / Neon |
| Redis Cache | ElastiCache | ApsaraDB Redis | TencentDB Redis | Upstash |
| CDN | CloudFront | CDN/DCDN | CDN/EdgeOne | Cloudflare CDN (free) |
| Load Balancer | ALB/NLB | SLB/ALB | CLB | Nginx self-hosted / Caddy |
| Serverless | Lambda | Function Compute | SCF | Cloudflare Workers |
| Containers/K8s | ECS/EKS | ACK | TKE | Fly.io / Railway |
| DNS | Route 53 | Alibaba Cloud DNS | DNSPod | Cloudflare DNS (free) |
| SSL Certs | ACM (free) | Free certs | Free certs | Let's Encrypt (free) |
| SES | Direct Mail | SES | Resend / SendGrid free tier | |
| SMS | SNS | SMS | SMS | Twilio |
| Monitoring | CloudWatch | Cloud Monitor | Cloud Monitor | Uptime Kuma (self-hosted) |
| AI/ML APIs | Bedrock | Tongyi Qianwen/Bailian | Hunyuan/TI | OpenAI / Anthropic API |
| Domain Registration | Route 53 | Wanwang | DNSPod | Namecheap / Cloudflare |
Q: Should I use cloud managed services or self-host everything on a VPS?Q: Should I use cloud managed services or self-host everything on a VPS?
Q: How do I use the AWS Free Tier without getting charged?Q: How do I use the AWS Free Tier without getting charged?
Q: AWS vs other VPS providers?Q: AWS vs other VPS providers?
------
If you're deploying AI Agents (not just regular web apps), there are platforms specifically designed for AI workloads:If you're deploying AI Agents (not just regular web apps), there are platforms specifically designed for AI workloads:
Website: https://modal.comWebsite: https://modal.com
Best for: Python AI projects needing GPU inference, scheduled jobs, batch data processingBest for: Python AI projects needing GPU inference, scheduled jobs, batch data processing
Features:Features:
modal deploy for one-command deploymentDefine functions with Python decorators, modal deploy for one-command deploymentpython import modal app = modal.App("my-ai-agent") @app.function(gpu="A10G", timeout=300) def run_agent(prompt: str): # Run your AI model/agent here return result
Website: https://huggingface.co/spacesWebsite: https://huggingface.co/spaces
Best for: Quickly showcasing AI demos (Gradio/Streamlit UI), open-source model displayBest for: Quickly showcasing AI demos (Gradio/Streamlit UI), open-source model display
Features:Features:
Website: https://replicate.comWebsite: https://replicate.com
Best for: Turning AI models into callable HTTP APIs without managing serversBest for: Turning AI models into callable HTTP APIs without managing servers
Push your model, Replicate packages it into an HTTP API, charges per call. Great for publishing fine-tuned models.Push your model, Replicate packages it into an HTTP API, charges per call. Great for publishing fine-tuned models.
Website: https://lambdalabs.comWebsite: https://lambdalabs.com
Best for: GPU-intensive training and inference at lower cost than AWS/GCP GPU instances. A100, H100, A10 available on-demand.Best for: GPU-intensive training and inference at lower cost than AWS/GCP GPU instances. A100, H100, A10 available on-demand.
------
This is the most important mindset for vibecoding-era deployment: You don't need to memorize every command โ AI is your DevOps assistant.This is the most important mindset for vibecoding-era deployment: You don't need to memorize every command โ AI is your DevOps assistant.
Mode 1: Generate scripts locally, execute manuallyMode 1: Generate scripts locally, execute manually
Tell your AI coding assistant (Claude Code, Trae Solo, Cursor):Tell your AI coding assistant (Claude Code, Trae Solo, Cursor):
> "I want to deploy [project description] to [platform/server]. Generate:> "I want to deploy [project description] to [platform/server]. Generate:
> 1. Complete step-by-step deployment checklist> 1. Complete step-by-step deployment checklist
> 2. All needed config files (Nginx, PM2, Dockerfile, docker-compose)> 2. All needed config files (Nginx, PM2, Dockerfile, docker-compose)
> 3. A deploy.sh deployment script> 3. A deploy.sh deployment script
> 4. Environment variable checklist"> 4. Environment variable checklist"
Then just execute what AI generates.Then just execute what AI generates.
Mode 2: AI SSHs directly to your server (even easier)Mode 2: AI SSHs directly to your server (even easier)
Claude Code supports remote SSH operations:Claude Code supports remote SSH operations:
bash claude # Tell it: # "SSH into root@MY-IP and deploy /root/myapp, configure Nginx + HTTPS + PM2"
AI will automatically check the environment, install missing dependencies, pull code, build, configure, and verify โ all without you typing commands manually.AI will automatically check the environment, install missing dependencies, pull code, build, configure, and verify โ all without you typing commands manually.
> โ ๏ธ Safety reminders:> โ ๏ธ Safety reminders:
> - Practice on a test server first to confirm AI won't make destructive changes> - Practice on a test server first to confirm AI won't make destructive changes
> - Back up important data regularly> - Back up important data regularly
> - Give AI a least-privilege user (don't give root; a sudo user is fine, but watch commands)> - Give AI a least-privilege user (don't give root; a sudo user is fine, but watch commands)
> - Before AI runs dangerous commands, review what it's about to do> - Before AI runs dangerous commands, review what it's about to do
No matter which platform/server you choose, fill this out and send it to AI for a complete actionable plan:No matter which platform/server you choose, fill this out and send it to AI for a complete actionable plan:
CODE Help me deploy a project with the following info: [DEPLOYMENT TARGET] - Platform/Server: [Vercel / Railway / Fly.io / Ubuntu 22.04 VPS / AWS EC2 / ...] - Server IP (if VPS): xxx.xxx.xxx.xxx - Already configured: [SSH key login / Docker installed / Nginx installed / ...] [PROJECT INFO] - Project type: [Next.js 14 / Vite+React / Node.js Express / Python FastAPI / ...] - Code location: GitHub repo https://github.com/xxx/xxx - Tech stack: Node.js 20 + PostgreSQL 16 + Redis 7 - Start command: npm run start - Listens on port: 3000 - Environment variables: DATABASE_URL=xxx, JWT_SECRET=xxx, OPENAI_API_KEY=xxx [DOMAIN] - Domain: mydomain.com - DNS already pointing to server: Yes/No - Need HTTPS: Yes/No [REQUIREMENTS] 1. Complete steps (list local vs server operations separately) 2. Provide all config files 3. Tell me how to verify successful deployment 4. List common gotchas and troubleshooting steps
When things break:When things break:
sudo tail -50 /var/log/nginx/error.logNginx: sudo tail -50 /var/log/nginx/error.logpm2 logs myappPM2: pm2 logs myappdocker compose logs appDocker: docker compose logs appsudo journalctl -u myapp -n 50systemd: sudo journalctl -u myapp -n 50> "Deploying Node.js to Ubuntu, getting 502 Bad Gateway. Nginx error log: [paste]. Config: [paste]. PM2 status: [paste]. Help me debug."> "Deploying Node.js to Ubuntu, getting 502 Bad Gateway. Nginx error log: [paste]. Config: [paste]. PM2 status: [paste]. Help me debug."
try_files for SPA routingRefresh gives 404: Nginx missing try_files for SPA routingpm2 logsPM2 keeps restarting: Code bug causing crash, check pm2 logs------
bash # Local โ Server scp ./file.zip yourname@IP:/home/yourname/ scp -r ./dir yourname@IP:/home/yourname/ # Server โ Local scp yourname@IP:/home/yourname/file.zip ./ # rsync (incremental sync, recommended for deployment) rsync -avz --exclude=node_modules --exclude=.git ./project/ yourname@IP:/var/www/project/
Create deploy.sh on your server:Create deploy.sh on your server:
bash #!/bin/bash set -e cd /path/to/project git pull origin main npm install npm run build pm2 restart myapp echo "โ Deployment complete!"
Updates are just bash deploy.sh. For full automation, set up GitHub Actions (ask AI to write the CI/CD config) so code pushes to main deploy automatically.Updates are just bash deploy.sh. For full automation, set up GitHub Actions (ask AI to write the CI/CD config) so code pushes to main deploy automatically.
Ask AI to generate a complete hardening script, which typically includes:Ask AI to generate a complete hardening script, which typically includes:
sudo apt install unattended-upgradesEnable automatic security updates: sudo apt install unattended-upgrades------
Deployment Options Summary:Deployment Options Summary:
| Scenario | Recommended | Cost | Difficulty |
|---|---|---|---|
| Pure frontend/docs | Cloudflare Pages / Vercel / GitHub Pages | Free | โญ |
| Next.js full-stack (fast response) | Vercel | Free / $20/mo | โญ |
| Backend API / Bot (always-on) | Railway / Fly.io (free) / VPS | $0-10/mo | โญโญ |
| Full-stack (full control) | DigitalOcean / Vultr / AWS EC2 + Docker | $4-10/mo | โญโญโญ |
| AI Agent demos | Hugging Face Spaces | Free | โญ |
| AI GPU inference | Modal (global) | $0-30/mo credit | โญโญ |
| Production with users | AWS/Azure/GCP managed services | Varies | โญโญโญ |
Remember the 5 core steps:Remember the 5 core steps:
Vibecoding mindset:Vibecoding mindset:
Deploy once and you'll realize โ getting online isn't that hard. ๐ฏDeploy once and you'll realize โ getting online isn't that hard. ๐ฏ
------
:articles="relatedArticlesMap['en/stage-2/backend/cloud-server-deployment']":articles="relatedArticlesMap['en/stage-2/backend/cloud-server-deployment']"
title="Related Articles"title="Related Articles"
description="Continue learning the engineering skills around deployment."description="Continue learning the engineering skills around deployment."
/>/>