Self-Host a Static Website at Home Using Raspberry Pi
Running your own website from home can be a rewarding project for IT enthusiasts and hobbyists. With just a Raspberry Pi, a domain name, and some simple network configuration, you can host a static website accessible to the world. In this guide, I’ll walk you through setting up a basic static site and making it publicly accessible.
What You’ll Need
- Raspberry Pi (any model, Pi 4 or Pi 5 recommended)
- Ubuntu 24.04 LTS Server Edition (or Raspberry Pi OS Lite)
- Domain name from a provider (Namecheap, Google Domains, Cloudflare, etc.)
- Home internet with access to your router settings
- A static HTML/CSS/JS site (or a placeholder index.html file)
Step 1: Prepare Your Raspberry Pi
- Flash Ubuntu 24.04 LTS Server (or your preferred OS) to an SD card.
- Boot your Pi and connect via SSH or directly with a keyboard/monitor.
- Update your system: sudo apt update && sudo apt upgrade -y
Step 2: Install a Web Server
We’ll use Nginx, a lightweight and fast web server.
sudo apt install nginx -y
To verify it’s running:
systemctl status nginx
You can place your website files inside:
/var/www/html/
Replace the default index.html with your own:
sudo nano /var/www/html/index.html
Step 3: Get Your Public IP Address
Visit whatismyip.com or run:
curl ifconfig.me
This IP is what you’ll point your domain to.
Step 4: Configure Your Domain
- Log in to your domain provider dashboard.
- Find the DNS management section.
- Add an A Record pointing your domain (example.com) to your public home IP address.
- (Optional) Add a
wwwCNAME record pointing to your root domain.
⚠️ Note: If your ISP changes your public IP frequently, consider using a Dynamic DNS service (like DuckDNS, No-IP, or Cloudflare DDNS).
Step 5: Port Forwarding on Your Router
By default, web traffic uses port 80 (HTTP) and 443 (HTTPS).
- Log in to your router’s admin panel.
- Find the Port Forwarding / NAT settings.
- Forward:
- External Port 80 → Raspberry Pi’s internal IP on port 80
- (Later) Port 443 → Raspberry Pi’s internal IP on port 443
Now, when visitors type your domain, the router forwards requests to your Pi.
Step 6: Test Your Website
- Open a browser and go to your domain (example.com).
- If everything is set up correctly, your static site should load!
Next Steps: Secure With HTTPS and Proxy
Right now, your site is running over plain HTTP. In the next blog post, I’ll show you how to:
- Use Nginx reverse proxy to handle multiple websites/services.
- Add free SSL certificates with Let’s Encrypt for HTTPS.
- Improve security and performance with caching.

Final Thoughts
Hosting a static website on a Raspberry Pi is a great first step into self-hosting. It’s lightweight, cost-effective, and gives you control over your own server. Whether it’s a personal blog, portfolio, or simple project site, you can proudly say, “I run this from my own home!”
Thank you so much for taking the time to read my post! Your support and engagement truly mean a lot and inspire me to keep creating and sharing more valuable content. If you enjoyed this post, I’d love to hear your thoughts—feel free to leave a comment in the box below and join the conversation. And if you’d like to stay updated with the latest posts, tips, and insights, don’t forget to subscribe to my newsletter. By joining, you’ll be the first to know when new content is published, so you never miss an update.
