CodeBrowser

We earn commissions when you shop through the links below. Learn more

How to Host a Website on a VPS (Step by Step)

Put your own website online on a VPS: point your domain, install Nginx, upload your site and add free HTTPS. Works for static sites, and shows the next steps for WordPress, Node.js and Docker apps.

Domain & DNSNginxFree HTTPSAbout 20 minutes

Before you start

What you need

A VPS

Any small Ubuntu server works for a typical website. 1 GB of RAM is plenty for static sites.

A domain name

From any registrar. You’ll point it at your server in step 1.

SSH access

A user with sudo and your SSH key, so you can log in and install software.

No server yet? Hostinger gives you 4 GB of RAM for about $5.19 a month with our extra 20% off, and DigitalOcean starts at about $4 a month with no commitment. Then follow our guide on how to set up a VPS before continuing.

Step 1

Point your domain at the server

At your domain registrar or DNS provider, create two records pointing to your server’s IP address. Changes usually take effect within minutes, but can take a few hours.

Check it’s working with ping example.com; it should show your server’s IP.

DNS records to add

TypeNameValue
A@203.0.113.10
Awww203.0.113.10

Steps 2–3

Install Nginx and upload your site

2. Install Nginx and open the firewall

sudo apt update
sudo apt install -y nginx
sudo ufw allow 'Nginx Full'

3. Upload your site from your computer

rsync -avz ./my-site/ deploy@203.0.113.10:/tmp/my-site/
ssh deploy@203.0.113.10 "sudo mkdir -p /var/www/example.com && sudo cp -r /tmp/my-site/. /var/www/example.com/"

Prefer drag and drop? Any SFTP app such as WinSCP, FileZilla or Cyberduck works too. Upload to your home folder, then copy the files into /var/www/example.com as above.

Steps 4–5

Configure Nginx and add free HTTPS

Create /etc/nginx/sites-available/example.com with this, replacing the domain:

server {
    listen 80;
    server_name example.com www.example.com;
    root /var/www/example.com;
    index index.html;

    location / {
        try_files $uri $uri/ =404;
    }
}

4. Enable the site

sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
sudo rm -f /etc/nginx/sites-enabled/default
sudo nginx -t && sudo systemctl reload nginx

5. Add free HTTPS with Let’s Encrypt

sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d example.com -d www.example.com

Open https://example.com: your site is live. Certbot renews the certificate automatically.

Other kinds of sites

Hosting WordPress, Node.js or Docker apps

WordPress

Needs PHP and a database alongside Nginx. Our WordPress on a VPS guide covers the full stack.

Node.js, Python or Go

Run the app on a local port (for example 3000) with a process manager like systemd or PM2, and point Nginx at it with proxy_pass http://127.0.0.1:3000;.

Docker apps

Run the container bound to 127.0.0.1 and use the same Nginx reverse proxy, so only HTTPS traffic reaches it.

Need a server?

Pick a server for your website

A static site or small blog runs happily on the cheapest plans. Pick more RAM if you plan to add WordPress or apps later.

Best overall

DigitalOcean

Simple cloud servers with great docs. Add your SSH key when you create a Droplet.

From about $4/month

View DigitalOcean deals
Most RAM for the money

Hostinger

4 GB of RAM and NVMe storage on the entry VPS plan, with an easy control panel.

About $5.19/month on a 24-month term with our extra 20% off

Get 20% off Hostinger VPS
Best budget

RackNerd

Yearly KVM VPS deals for about the price of one month elsewhere. Great for learning.

From about $11/year on promo

View RackNerd deals

Prices are approximate and change often. Check each provider’s site before you buy.

FAQ

Website hosting questions, answered

Is a VPS better than shared hosting for a website?

A VPS is faster, more flexible and isolated from other customers, and it can host as many sites as it has room for. Shared hosting is easier because the host manages the server, but you have less control.

How many websites can one VPS host?

Many. Each site gets its own folder and Nginx server block. A small VPS can serve dozens of static sites or several dynamic ones, depending on traffic.

Do I need a control panel?

No. Nginx is configured with simple text files, as shown above. If you prefer a dashboard, free panels such as CloudPanel or HestiaCP can manage sites for you.

Why does my domain not load the site yet?

DNS changes can take a while to spread. Check that your A records point to the right IP with ping, that Nginx is running, and that the firewall allows Nginx Full.

Is HTTPS really free?

Yes. Let’s Encrypt certificates are free, trusted by all browsers, and renewed automatically by Certbot.

How do I update my site later?

Run the same rsync command again. It only uploads files that changed, so updates take seconds.

Need a server for your site?

Compare the best VPS hosting on price, RAM and locations, from budget yearly deals to developer clouds.

Compare VPS hosting