How to Host a Website on DigitalOcean (Beginner's Guide)
Once you have a DigitalOcean Droplet running, the next thing most people want to do is put a website on it. This guide shows you how — step by step, in plain English.
We'll install a web server called Nginx (pronounced "engine-X"), upload your site files, point your domain to the server, and turn on HTTPS. By the end, your site will be live and secure.
Don't have a Droplet yet? Start with our guide to creating your first DigitalOcean Droplet, then come back here.
What You'll Need
- A running DigitalOcean Droplet with Ubuntu 24.04
- SSH access to your server
- A domain name (optional but recommended for a real site)
- Your website files (HTML, CSS, JS — or a WordPress install works too)
Step 1: Update Your Server
Before installing anything new, bring the server's software list up to date. Log in via SSH, then run:
1sudo apt update && sudo apt upgrade -y
This downloads the latest package information and installs any pending updates. It may take a couple of minutes. The -y flag means "yes to everything" — it won't stop to ask you to confirm each update.
Step 2: Install Nginx
Nginx is the web server — the software that listens for requests and sends your site files to visitors' browsers. It's fast, widely used, and free.
Install it:
1sudo apt install nginx -y
Once installed, Nginx starts automatically. Check that it's running:
1sudo systemctl status nginx
You should see active (running) in green. Nginx is now live.
Test it in a browser: Open a browser and type your Droplet's IP address (e.g., http://143.198.32.15). You should see the default Nginx welcome page — a simple "Welcome to nginx!" message. That means the web server is working.
Step 3: Allow Web Traffic Through the Firewall
If you set up UFW in the previous guide, you need to tell the firewall to let web traffic through:
1sudo ufw allow 'Nginx Full'
Nginx Full opens both port 80 (regular HTTP) and port 443 (HTTPS). You'll need both.
Step 4: Upload Your Website Files
By default, Nginx serves files from /var/www/html. That's where your website lives on the server.
Option A — For a static site (HTML/CSS/JS files):
From your local computer (not the server), use scp to copy your files up:
1scp -r /path/to/your/site/* yourname@YOUR_IP:/var/www/html/
Replace /path/to/your/site/ with the folder on your computer that contains your site files, and yourname@YOUR_IP with your server username and IP address.
Option B — Edit files directly on the server:
If you're starting from scratch, you can create a simple test page directly on the server:
1sudo nano /var/www/html/index.html
Type or paste your HTML, then press Ctrl+X, then Y, then Enter to save. Refresh the IP address in your browser — you should see your page.
Step 5: Point Your Domain to DigitalOcean
If you have a domain name, you'll want yourdomain.com to show your site instead of a raw IP address.
In your domain registrar's DNS settings, create an A record:
| Type | Name | Value | TTL |
|---|---|---|---|
| A | @ | Your Droplet IP | 3600 |
| A | www | Your Droplet IP | 3600 |
The @ points the root domain (yourdomain.com) to your server. The www points the www version. DNS changes can take up to 48 hours to fully propagate, but usually work within an hour.
In DigitalOcean, you can also manage DNS from the control panel under Networking → Domains. This isn't required if you're handling DNS at your registrar, but it's a useful option if you want everything in one place.
Step 6: Set Up Nginx for Your Domain
Once DNS is pointing to your server, tell Nginx to serve your site when visitors arrive at your domain name.
Create a configuration file for your site:
1sudo nano /etc/nginx/sites-available/yourdomain.com
Paste in this configuration (replace yourdomain.com with your actual domain):
1server {
2 listen 80;
3 server_name yourdomain.com www.yourdomain.com;
4 root /var/www/html;
5 index index.html index.htm;
6
7 location / {
8 try_files $uri $uri/ =404;
9 }
10}
Save the file (Ctrl+X, Y, Enter).
Enable the site:
1sudo ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/
2sudo nginx -t
3sudo systemctl reload nginx
The nginx -t command checks your configuration for errors before applying it. If it says test is successful, you're good.
Step 7: Enable HTTPS (Free SSL Certificate)
A padlock in the browser address bar tells visitors your site is secure. You can get a free SSL certificate from Let's Encrypt and Nginx will handle everything else.
Install Certbot (the tool that gets and renews the certificate):
1sudo apt install certbot python3-certbot-nginx -y
Get your certificate:
1sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
Certbot will ask for your email address, ask you to agree to the terms, and then do the rest automatically. It sets up HTTPS and configures Nginx to redirect HTTP to HTTPS.
When it's done, visit https://yourdomain.com in your browser. You should see the padlock. Your site is now live and secure.
Certbot automatically renews the certificate before it expires — you don't need to do anything.
Your Site Is Live
You now have a website running on your own server, on your own domain, with HTTPS. The monthly cost is $6 for the smallest DigitalOcean Droplet — no shared-hosting limits, no mystery traffic throttling, no upsell emails.
From here you can:
- Install WordPress with a one-command script
- Deploy a Node.js, Python, or PHP application
- Add more domains to the same server by creating additional Nginx config files